Question

In: Computer Science

1. Use SQL to create a polyinstantiated table including a primary key and a unique constraint...

1. Use SQL to create a polyinstantiated table including a primary key and a unique constraint

2.Use SQL to insert multiple records for each security classification with the same ID. You must have 4 classifications.

3.Use SQL to create 4 schemas, one for each security classification 4.Use SQL to create a view in each schema that restricts the records to those belonging to a particular security classification and restricts the columns to only those columns that have relevant data.

5.Select from each of the views. Take a screen shot of the query results for each user(total of 4 for this step).

6.Use SQL to create 4 logins, one for eachsecurity classification

7.Use SQL to create 4 database users, one for each login with a default schema that matches the security classification for the login.

8.Use SQL to create 4 roles at the database level, one for each security classification.

9.Use SQL to assign each user to its specific role.

10.Use SQL to grant select on the appropriate view to the roles.

11.Execute tests as each of the four users, trying to select from their respective views. Take a screen shot of the query results for each user(total of 4 for this step).

12.Use SQL to revoke select on the view from the role

13.Use SQL to remove the users from the role

14.Use SQL to drop the users

15.Use SQL to drop the logins

16.Use SQL to drop the roles1

7.Use SQL to drop the views

18.Use SQL to drop the schemas

19.Use SQL to drop the table

Solutions

Expert Solution

(1).Use SQL to create a polyinstantiated table including a primary key and a unique constraint

CREATE TABLE Persons (
    ID int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    PRIMARY KEY (ID)
);

(2).Use SQL to insert multiple records for each security classification with the same ID. You must have 4 classifications.

ANSWER: to insert multiple records in a table we use INSERT statement

INSERT INTO table_name (column_list)
VALUES (value_list_1), (value_list_2), ... (value_list_n);

(3).Use SQL to create 4 schemas, one for each security classification

SELECT s.name AS schema_name, u.name AS schema_owner FROM sys.schemas s INNER JOIN sys.sysusers u ON u.uid = s.principal_id ORDER BY s.name;

(4).Use SQL to create 4 logins, one for eachsecurity classification

-- Create a login for SQL Server by specifying a server name and a Windows domain account name.  

CREATE LOGIN [<domainName>\<loginName>] FROM WINDOWS;  

(5).Use SQL to create 4 database users, one for each login with a default schema that matches the security classification for the login.

   

CREATE LOGIN Khamal  

WITH PASSWORD = '340$Uuxwp7Mcxo7Khy';  

GO  

-- Creates a database user for the login created above.  

CREATE USER AbolrousHazem FOR LOGIN AbolrousHazem;  

GO

(8).Use SQL to create 4 roles at the database level, one for each security classification

CREATE TABLE Sales(

    UserName khamal(50),

    Country khamal(50),

    Sales INT

)

    

INSERT INTO Sales VALUES ('tred','nepal',10000)

INSERT INTO Sales VALUES ('sam','india',9500)

INSERT INTO Sales VALUES ('Tam','France',9600)

INSERT INTO Sales VALUES ('Fola','Spain',9200)

INSERT INTO Sales VALUES ('Chris','Germany',9000)

(9).Use SQL to assign each user to its specific role

CREATE USER 'dev1'@'localhost' IDENTIFIED BY 'manager'; CREATE USER 'read_user1'@'localhost' IDENTIFIED BY 'assistant manager'; CREATE USER 'read_user2'@'localhost' IDENTIFIED BY 'watch man'; CREATE USER 'rw_user1'@'localhost' IDENTIFIED BY 'clerk';

(10).Use SQL to grant select on the appropriate view to the roles

GRANT <permission> [ ,...n ] ON

[ OBJECT :: ][ schema_name ]. object_name [ ( column [ ,...n ] ) ]  

TO <database_principal> [ ,...n ]

[ WITH GRANT OPTION ]  

[ AS <database_principal> ]  

  

<permission> ::=  

ALL [ PRIVILEGES ] | permission [ ( column [ ,...n ] ) ]  

  

<database_principal> ::=

Database_user

| Database_role

| Application_role

| Database_user_mapped_to_Windows_User

| Database_user_mapped_to_Windows_Group

| Database_user_mapped_to_certificate

| Database_user_mapped_to_asymmetric_key

| Database_user_with_no_login

(12).Use SQL to revoke select on the view from the role

REVOKE [ GRANT OPTION FOR ] <permission> [ ,...n ] ON

[ OBJECT :: ][ schema_name ]. object_name [ ( column [ ,...n ] ) ]  

{ FROM | TO } <database_principal> [ ,...n ]

[ CASCADE ]  

[ AS <database_principal> ]  

  

<permission> ::=  

ALL [ PRIVILEGES ] | permission [ ( column [ ,...n ] ) ]  

  

<database_principal> ::=

Database_user

| Database_role

| Application_role

| Database_user_mapped_to_Windows_User

| Database_user_mapped_to_Windows_Group

| Database_user_mapped_to_certificate

| Database_user_mapped_to_asymmetric_key

| Database_user_with_no_login

(13).Use SQL to remove the users from the role

EXEC sp_droprolemember 'operator', 'John';

(14).Use SQL to drop the users

  DROP USER [ IF EXISTS ] user_name

(15).Use SQL to drop the logins

DROP LOGIN login_name

(16).Use SQL to drop the roles1

  

DROP ROLE [ IF EXISTS ] role_name

(17).Use SQL to drop the views

  

DROP VIEW [ IF EXISTS ] [ schema_name . ] view_name [ ...,n ] [ ; ]

(18).Use SQL to drop the schemas

  

  

DROP SCHEMA [ IF EXISTS ] schema_name

(19).Use SQL to drop the table

DROP TABLE [IF EXIST] table_name


Related Solutions

Create a table in SQL with foreign key reference: 1.Create the three tables without any columns...
Create a table in SQL with foreign key reference: 1.Create the three tables without any columns 2.Alter the tables to add the columns 3.Alter the tables to create the primary and foreign keys
Create table, create primary and foreign key constraints. Create index on the table to satisfy a...
Create table, create primary and foreign key constraints. Create index on the table to satisfy a query with aggregate functions.
create table node( node_id integer primary key, node_color varchar(10)); create table edge( edge_id integer primary key,...
create table node( node_id integer primary key, node_color varchar(10)); create table edge( edge_id integer primary key, origin_id integer, destination_id integer, foreign key (origin_id) references node(node_id), foreign key (destination_id) references node(node_id)); write an SQL query that lists all those nodes that have edges with a destination node that has color 'red'.
Use a single SQL statement to create a relational table and to load into the table...
Use a single SQL statement to create a relational table and to load into the table department name, subject code, year of running and session of running that offered by the departments. Note that a running subject offered by a department means a lecturer of the department has been assigned to teach the subject. Next, enforce the appropriate consistency constraints on the new table.    When ready use SELECT statement to list the contents of the relational table created and...
Consider the following SQL DDL statements: CREATE TABLE DEPT ( did INTEGER, dname VARCHAR(20), PRIMARY KEY(did));...
Consider the following SQL DDL statements: CREATE TABLE DEPT ( did INTEGER, dname VARCHAR(20), PRIMARY KEY(did)); CREATE TABLE EMP( eid INTEGER, name VARCHAR(20), did INTEGER, PRIMARY KEY(eid), FOREIGN KEY(did) REFERENCES DEPT); In the database created by above statements, which of the following operations may cause violation of referential integrity constraints? Question 1 options: UPDATE on DEPT INSERT into DEPT DELETE on EMP Both DELETE on EMP and INSERT into DEPT
Consider the following table definitions create table node( node_id integer primary key, node_color varchar(10)); create table...
Consider the following table definitions create table node( node_id integer primary key, node_color varchar(10)); create table edge( edge_id integer primary key, origin_id integer, destination_id integer, foreign key (origin_id) references node(node_id), foreign key (destination_id) references node(node_id)); What is the result of the following query? select node_id, node_color, destination_id from node, edge; An inner join of the tables node and edge that lists origin node_id and node_color together with the node_id of the destination node for all those nodes that have outgoing...
USE SQL CREATE TABLE IF NOT EXISTS football_games ( visitor_name VARCHAR(30),       /* Name of the visiting...
USE SQL CREATE TABLE IF NOT EXISTS football_games ( visitor_name VARCHAR(30),       /* Name of the visiting team                     */ home_score SMALLINT NOT NULL,   /* Final score of the game for the Buffs         */ visitor_score SMALLINT NOT NULL,/* Final score of the game for the visiting team */ game_date DATE NOT NULL,        /* Date of the game                              */ players INT[] NOT NULL,         /* This array consists of the football player ids (basically a foreign key to the football_player.id) */ PRIMARY KEY(visitor_name, game_date)...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table: Customer...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table: Customer PK Customer ID Text Phone Number int name text address ID int email text FK vendor ID int Vendor is the name of the table the FK comes from.
In the MedicalVisit table the primary key is defined as (Date, Doctor, Patient).     1. If the...
In the MedicalVisit table the primary key is defined as (Date, Doctor, Patient).     1. If the primary key were to be changed to (Doctor, Patient), how would it affect the design and information in the database?  (eg information structure in the database, normal form etc.) 2.  Please Draw an ER diagram based on the above original Relational Model
-- Creating table ProjDept: create table ProjDept ( ProjDeptID NUMBER(10) primary key, ProjDeptName varchar2(20), OfficeLocation varchar2(20),...
-- Creating table ProjDept: create table ProjDept ( ProjDeptID NUMBER(10) primary key, ProjDeptName varchar2(20), OfficeLocation varchar2(20), PhoneNumber varchar2(20) ); INSERT INTO ProjDept (ProjDeptID, ProjDeptName, OfficeLocation, PhoneNumber) VALUES (1001, 'Accounting','ITCC01-400','888-285-8100'); (2001, 'Human Resources','ITCC01-200','888-285-8100'); (3001, 'Marketing','ITCC02-300','888-285-8100'); (4001, 'Information Techn','ITCC02-100','888-285-8100'); (5001, 'Legal','ITCC01-100','888-285-8100'); -- Creating table Employee: create table Employee( EmployeeID NUMBER(10) primary key, FirstName varchar2(20), LastName varchar2(20), ProjDeptID NUMBER(10), PhoneNumber varchar2(20) ); INSERT INTO Employee (EmployeeID, FirstName, LastName, ProjDeptID, PhoneNumber, Email) VALUES (10, 'Mark','Columbus',1001, '888-285-8101', '[email protected]'); (29, 'Elvin','Wahl', 2001, '888-285-8201', '[email protected]'); (38, 'Taylor','Noel',...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT