(3a) SQL question. See attachment.
(3A)There are two parts to this assignment, part A and B. Make sure to complete all of them.
Part A: Normalization
Briefly explain what the 1st, 2nd, and 3rd normal forms are, and identify each of these normal forms in the dependency diagram shown in the following figure:
Use the above dependency diagram as an example; draw the dependency diagram for the following student table:
Use Microsoft Word for this part (Part A) of the assignment. When you are done, submit this document to the Module 3 Dropbox as part of the Module 3 Assignment.
Part B: Write SQL command to create tables and make queries
Note: you are required to use Oracle Live SQL to accomplish the following tasks. Copy your work to a notepad file, and save it as mod3Truck.sql.
Three tables are related to this part of the assignment: Base, Type, Truck table. The structure of each table and associated attributes are listed below:
Table name: BASE
Primary key: BASENUM
Attribute (Field) Name | Data Declaration |
BASENUM | CHAR(3) |
BASECITY | VARCHAR2(20) |
BASESTATE | CHAR(2) |
BASEPHON | VARCHAR2(10) |
BASEMGR | VARCHAR2(10) |
Table name: TYPE
Primary key: TYPENUM
Attribute (Field) Name | Data Declaration |
TYPENUM | CHAR(1) |
TYPEDESC | VARCHAR2(30) |
Table name: TRUCK
Primary key: TNUM
Foreign key: BASENUM, TYPENUM
Attribute (Field) Name | Data Declaration |
TNUM | CHAR(4) |
BASENUM | CHAR(3) |
TYPENUM | CHAR(1) |
TMILES | NUMBER(7,1) |
TBOUGHT | DATE |
TSERIAL | VARCHAR2(20) |
Create these three tables with appropriate primary and foreign key declaration. The order in which these three tables are created matters in this assignment. Pay special attention to referential integrity among the tables. Create the BASE table first, then the TYPE table, and finally the TRUCK table (since the TRUCK
- table is the one that has foreign keys). Debug your code till it is bug free.
Populate these three tables with the following data.
|
|
|
Write SQL commands to accomplish the following tasks:
Display truck number; buy date, mileage, and serial number of all trucks.
Display truck number, buy date, and mileage of all trucks with Dallas as their base.
Display truck number and buy date of all trucks with Dallas as their base and with mileage lower than 30,000 miles.