Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

DPIT115 Data Management and Security

Final Assessment

Spring Session 2022

QUESTIONS 2, 3, and 4 REFER TO THE RELATIONAL TABLES

LISTED BELOW

CREATE TABLE EMPLOYEE(

DECIMAL(12)

VARCHAR(50)

VARCHAR(50)

DATE

CONSTRAINT EMPLOYEE_PKEY PRIMARY KEY(STAFFENUM) );


*/

*/

*/

*/

CREATE TABLE DRIVER(

 

 

 

STAFFENUM DECIMAL(12)

NOT NULL,

/* Employee number

*/

LICENSENUM  DECIMAL(8)

NOT NULL,

/* Driving license number

*/

STATUS      VARCHAR(10)

NOT NULL,

/* Driver status

*/

CONSTRAINT DRIVER_PKEY PRIMARY KEY(STAFFNUM),

CONSTRAINT DRIVER_UNIQUE UNIQUE(LICENSENUM),

CONSTRAINT DRIVER_FKEY FOREIGN KEY(STAFFNUM) REFERENCES EMPLOYEE(STAFFNUM), CONSTRAINT DRIVER_STATUS CHECK (

STATUS IN ('AVAILABLE', 'BUSY', 'ON LEAVE')) );

CREATE TABLE TRUCK(

REGNUM

VARCHAR(10)

NOT NULL,

/* Registration number

*/

CAPACITY

DECIMAL(7)

NOT NULL,

/* Capacity

*/

WEIGHT

DECIMAL(7)

NOT NULL,

/* Weight

*/

STATUS

VARCHAR(10)

NOT NULL,

/* Present status

*/

CONSTRAINT CONSTRAINT

CONSTRAINT

CONSTRAINT

TRUCK_PKEY PRIMARY KEY(REGNUM),

TRUCK_STATUS CHECK

( STATUS IN ('AVAILABLE', 'USED', 'MAINTAINED')),

TRUCK_WEIGHT CHECK

( WEIGHT > 0.0 AND WEIGHT < 500 ),

TRUCK_CAPACITY CHECK

( CAPACITY > 0.0 AND CAPACITY < 100 ) );

CREATE TABLE TRIP(

 

 

 

TRIPNUM     DECIMAL(10)

NOT NULL,

/* Trip number

*/

LICENSENUM  DECIMAL(8)

NOT NULL,

/* Driving license number

*/

REGNUM      VARCHAR(10)

NOT NULL,

/* Truck registration number

*/

TDATE       DATE

NOT NULL,

/* Trip date

*/

CONSTRAINT TRIP_PKEY PRIMARY KEY (TRIPNUM),

CONSTRAINT TRIP_CKEY UNIQUE (LICENSENUM, REGNUM, TDATE),

CONSTRAINT TRIP_FKEY1 FOREIGN KEY (LICENSENUM) REFERENCES DRIVER(LICENSENUM), CONSTRAINT TRIP_FKEY2 FOREIGN KEY (REGNUM) REFERENCES TRUCK(REGNUM) );

CREATE TABLE TRIPLEG(

TRIPNUM     DECIMAL(10)       NOT NULL,         /* Trip number

LEGNUM      DECIMAL(2)        NOT NULL,         /* Leg number

DEPARTURE   VARCHAR(30)       NOT NULL,         /* Departure city

DESTINATION VARCHAR(30)       NOT NULL,         /* Destination city

CONSTRAINT TRIPLEG_PKEY PRIMARY KEY (TRIPNUM, LEGNUM),

CONSTRAINT TRIPLEG_UNIQUE UNIQUE(TRIPNUM, DEPARTURE, DESTINATION),        CONSTRAINT TRIPLEG_FKEY1 FOREIGN KEY (TRIPNUM) REFERENCES TRIP(TRIPNUM) );

*/

*/

*/

*/

QUESTION 1 (10 marks)

Consider the conceptual schema given below.

 

Your task is to perform the steps of logical database design, i.e. to transform a conceptual schema given above into a collection of relational schemas.

Before transforming add the attribute Moodle-link’ to the SUBJECT-DESCRIPTION class and campus’ to the LECTURER class.

Draw the resulting conceptual schema adding your name, student number and the date to the drawing. Use UMLet and paste images of your drawings into your Microsoft Word document using the template      provided.

List the names of attributes, primary key, candidate keys (if any), and foreign keys (if any) for each class in the relational schema. Assume that an association method is used to implement the generalisation.

Show your working and explain as you step through the transformation process.

Convert your Microsoft Word document based on the template provided into a pdf and submit your answer as a file question1.pdf

If a submitted file has an incorrect filename or file type, it may lose marks.

QUESTION 2 (10 marks)

Write the data definition statements of SQL that modify the structures of a database listed on page 2 of this assessment in the way described below.

Note, that some of the modification may require more than one SQL data definition statement.

(1)       Modify the consistency constraint of the sample database such that after the modification, it is possible to record in the database information about the trucks that have a capacity up to and including 500(2 marks)

(2)       Modify the structure and consistency constraints of the sample database such that after the           modification, it is possible to store information in the database about the total number of legs a trip contains. Assume that a trip cannot contain more than 15 legs. (2 marks)

(3)       Modify the structure and consistency constraints of the sample database such it is possible to store information in the database about the mechanics employed by a transportation company. Assume  that a description of mechanic consists of an employee number, first name, last name, date of   birth and qualification level. A qualification level is a positive integer number 1 or 2 or 3 or 4 or 5. Remember that a mechanic is an employee. (2 marks)

(4)       Modify the consistency constraints of the sample database, so it is possible to store information about the trip without providing information about a driver licence number. Such modification is required when a driver leaves a transportation company , and we would like to keep information about all trips performed by the driver. (2 marks)

(5)       Explain how the use of consistency constraints support the management of data security. Use original examples to illustrate your answer. (2 marks)

Add your code into the question2.sql template provided and output your report file on your virtual machine to a file named question2.rpt.

Add your name, student number and the date to the comments section of your SQL script.

Submit your answers as the files question2.sql,question2.rpt and question2.pdf using the templates provided.

Note your script may be tested and should not have any errors when run.

If a submitted file has an incorrect filename or file type, it may lose marks.

QUESTION 3 (10 marks)

Write the data manipulation statements of SQL that modify the contents of a database listed on page 2 of this lab task in the ways described below.

Note that you are not allowed to modify and/or to drop any consistency constraints. Also note, that to implement some of the modifications listed below, you may need more than one data manipulation   statement.

(1)       A new trip has been completed today. The trip was from Wollongong to Canberra. The trip has       been performed by the driver with the licence number 112959 (column LICENSENUM in a relational table TRIP) who used the truck with registration number AC07ZU. Insert the appropriate information into the sample database assuming the next trip number is 23409(2 marks)

(2)       Delete the information from the database about trip number 42. Remember, that the foreign keys in all CREATE TABLE statements have no ON DELETE CASCADE clause. (2 marks)

(3)       Change the status of all the drivers who have performed more than 50 trips to be ON LEAVE(2 marks)

(4)       Copy information about all employees born before the year 2000 to a new table S20CENTB4. There is no need to enforce any consistency constraints on the new table. (2 marks)

(5)       Explain how the data manipulation statements of SQL are used in data management and security. Use original examples to illustrate your answer. (2 marks)

Submit your answer as files named question3.sql and question3.pdf using the templates provided. Add your name, student number and the date to the comments section of your SQL script.

If a submitted file has an incorrect filename or file type, it may lose marks.

QUESTION 4 (10 marks)

Assume that the user root with a password 'DPIT115' created a database called transport and the user root executed CREATE TABLE statements given on page 2 of the examination paper to create the      relational tables in the database transport.

Write a SQL script that performs the following operations the user root . Assume that the user root has already connected to the database.

The user root’ nominates a database transport as a default database, and then the user creates two roles driver’ and admin’ . (1 mark)

The user root’ grants read access rights to the relational tables EMPLOYEE and DRIVER to the role ‘admin’ . The read access rights cannot be propagated to other roles or users. (1 mark)

The user root’ grants the rights to insert the rows into a relational tables TRIP and TRIPLEG to the role ‘driver’ . The access rights can be propagated to other roles or users. (1 mark)

The user root’ grants the update privilege on all relational tables in the transport database to the role ‘admin’ . The privilege cannot be propagated to other roles or users. (1 mark)

The user root’ grants the read access rights to information about the total number of trips performed by each driver to a role driver’ . (1 mark)

The user root’ creates seven (7) new users and grants the role driver’ to three (3) of the users, and the role admin’ to the all other users. The names and passwords of the new user accounts

are up to you.                              (1mark)

The user root’ sets the resource limits for the users created in the previous step allowing five (5)  maximum concurrent connections. Finally, the user root’ locks all the user accounts created in the previous step. (1 mark)

Explain in your own words how the security management functions built into a database            management system can contribute to data security and consistency. Use original examples to illustrate your answer. (3 marks)

Add your code into the question4.sql template provided and output your report file on your virtual machine to a file named question4.rpt

Add your name, student number and the date to the comments section of your SQL script.

Submit your answers as files named question4.sql, question4.rpt and question4.pdf, use the templates provided.

Note your script may be tested and should not have any errors when run.

If a submitted file has an incorrect filename or file type, it may lose marks.