Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write down again and make sure which sentence corrects which line? Write the data definition statements of SQL that modify the structures of a

image text in transcribedimage text in transcribedimage text in transcribed

Please write down again and make sure which sentence corrects which line?

Write the data definition statements of SQL that modify the structures of a database listed on page 2 of this assessmert in the way described below. Note, that some of the modifications may require more than one SQL data definition statement. (1) Modify the consis tency 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 225. (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 10 legs. (2 marks) (3) Modify the structure of the sample database so it is possible to store information in a new table in the database about mechanics employed by a transportation company. Assume that a description of a 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 or 6 . Remember that a mecharic is an employee. (2 marks) (4) Modify the consis tency 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 supports the management of data security. Use original examples that you make up yourself to illustrate your answer. (2 marks) Add your code into the question2.sql template provided and output your report flle 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.question 2. pt and question2.pdf using the templates provided. Note your script may be tested and should not have any errors when run. CREATE TABLE EMPLOYEE ( EMPNUM DECIMAL (12) NOT NULL, /* Employee number \begin{tabular}{llll} \multicolumn{2}{c}{/} \\ FIRSTNAME VARCHAR (50) NOT NULL, & /* First name & \\ LASTNAME VARCHAR (50) NOT NULL, & / Last name & / \\ DOB & DATE NULL, & /* Date of birth & / \\ CONSTRAINT EMPLOYEE_PKEY PRIMARY KEY (EMPNMM) ); \end{tabular} CONSTRAINT DRIVER_PKEY PRIMARY KEY (EMPNUM), CONSTRAINT DRIVER_UNIQUE UNIQUE (LICENSENUM), CONSTRAINT DRIVER_FKEY FORE IGN KEY (EMPNUM) REFERENCES EMPLOYEE (EMPNUM), 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 TRUCK_PKEY PRIMARY KEY (REGNM), CONSTRAINT TRUCK_STATUS CHECK (STATUS IN ('AVAILABLE', 'USED', 'MAINTAINED') CONSTRAINT TRUCK_WEIGHT CHECK (WEIGHT >0.0 AND WEIGHT ), CONSTRAINT TRUCK_CAPACITY CHECK ( CAPACITY >0.0 AND CAPACITY

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions