The Relational Database Model CST272
Return
Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of two or more fields) that uniquely identifies each record Purchase Order Report
Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Extension, Subtotal, Tax, Shipping, Discount, PO total) Unnormalized Table Purchase Order Report
The Unnormalized Purchase Order Table Purchase Order Report Return
To Convert from Unnormalized to 1NF n Identify, list and remove repeating groups n Modify Primary key (concatenated fields) n Important: In 1NF there always will still be just one table
Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Repeating Groups The Unnormalized Purchase Order Table Purchase Order Report
The Payables Table in 1NF Return Purchase Order Report
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) 1NF (First Normal Form) Purchase Order Report The Payables Table in 1NF
To Convert from 1NF to 2NF n Identify the determinants – A listing of every possible combination of elements (fields) that make up the 1NF primary key n Identify the functional dependencies – Which non-key fields rely on which determinants to determine their value n For the new 2NF tables, the determinants are the primary keys
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number Product number PO number, Product number Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date Product number PO number, Product number Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number Product number PO number, Product number Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name Product number PO number, Product number Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name, Address Product number PO number, Product number Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name, Address, City Product number PO number, Product number Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name, Address, City, State Product number PO number, Product number Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code Product number PO number, Product number Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code Product number Product PO number, Product number Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code Product number Product PO number, Product number Unit price Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code Product number Product PO number, Product number Unit price, Quantity Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal Product number Product PO number, Product number Unit price, Quantity Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax Product number Product PO number, Product number Unit price, Quantity Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping Product number Product PO number, Product number Unit price, Quantity Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount Product number Product PO number, Product number Unit price, Quantity Functional Dependencies
Payables (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Product number, Product, Unit price, Quantity, Subtotal, Tax, Shipping, Discount, PO total) Determinants PO number PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total Product number Product PO number, Product number Unit price, Quantity Functional Dependencies
Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total) Payables (PO number, Product number, Unit price, Quantity) Product (Product number, Product) 2NF (Second Normal Form) Purchase Order Report
To Convert from 2NF to 3NF n Within the existing 2NF tables, identify the non-key determinants – Any non-key fields that could be a primary key for other fields in one of the 2NF tables n Identify those functional dependencies n Create new table(s) from the determinant(s) and functional dependency(cies) n Do not remove the non-key determinant(s) from original table(s)
Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total) Payables (PO number, Product number, Unit price, Quantity) Product (Product number, Product) Non-key Determinants
Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total) Payables (PO number, Product number, Unit price, Quantity) Product (Product number, Product) Vendor number Non-key Determinants
Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total) Payables (PO number, Product number, Unit price, Quantity) Product (Product number, Product) Vendor number Vendor name Non-key Determinants
Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total) Payables (PO number, Product number, Unit price, Quantity) Product (Product number, Product) Vendor number Vendor name, Address Non-key Determinants
Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total) Payables (PO number, Product number, Unit price, Quantity) Product (Product number, Product) Vendor number Vendor name, Address, City Non-key Determinants
Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total) Payables (PO number, Product number, Unit price, Quantity) Product (Product number, Product) Vendor number Vendor name, Address, City, State Non-key Determinants
Purchase Order (PO number, PO date, Vendor number, Vendor name, Address, City, State, ZIP code, Subtotal, Tax, Shipping, Discount, PO total) Payables (PO number, Product number, Unit price, Quantity) Product (Product number, Product) Vendor number Vendor name, Address, City, State, ZIP code Non-key Determinants
Vendor (Vendor number, Vendor name, Address, City, State, ZIP code) Purchase Order (PO number, Vendor number, Subtotal, Tax, Shipping, PO total, PO date) Payables (PO number, Product number, Unit price, Quantity) Product (Product number, Product) 3NF (Third Normal Form)
Finalize the Tables in Database Design Language n Present the 3NF tables with all keys: – Primary keys—that field which uniquely identifies (differentiates) a record from all other records in the table – Alternate (secondary) keys—a field that could have been the primary key but is not; DBMS must enforce that values of field are unique for every record – Foreign keys—a field that links to field values in another table; a foreign key value must match the primary key of one of the records in table to which it joins, or be null
Vendor (Vendor number, Vendor name, Address, City, State, ZIP code) Purchase Order (PO number, Vendor number, Subtotal, Tax, Shipping, PO total, PO date) FK Vendor number Vendor Payables (PO number, Product number, Unit price, Quantity) FK PO number Purchase Order FK Product number Product Product (Product number, Product) DBDL (Database Design Language)
Vendor (Vendor number, Vendor name, Contact, Telephone) Unnormalized—Contact Listing
Vendor (Vendor number, Vendor name, Contact, Telephone) DBDL—Contact Listing
Merge the Tables n If you have two tables with the identical primary key, they generally should be merged into a single table n The results of each new normalization should be merged into the existing tables from previous normalizations
Vendor (Vendor number, Vendor name, Address, City, State, ZIP code, Contact, Telephone) Purchase Order (PO number, Vendor number, Subtotal, Tax, Shipping, PO total, PO date) FK Vendor number Vendor Payables (PO number, Product number, Unit price, Quantity) FK PO number Purchase Order FK Product number Product Product (Product number, Product) DBDL—The Merged Tables
Vendor (Vendor number, Vendor name, Address, City, State, ZIP code, Contact, Telephone, Fax, Term days, Term percent, Date last order) Purchase Order (PO number, Vendor number, Subtotal, Tax, Shipping, PO total, PO date, Bill date, Discount date, Due date) FK Vendor number Vendor Payables (PO number, Product number, Unit price, Quantity, Back ordered?) FK PO number Purchase Order FK Product number Product Product (Product number, Product) DBDL—The Final Tables
Mini Quiz n Normalize a “Student Transcript”using the model given from the “Payables” database Student Transcript Student ID: 345Advisor ID: 56 Student Name: Sally HensonAdvisor name: Ralph Pollard Credits completed: 32Advisor office: H203 Class standing: FreshmanAdvisor phone: Course numberGrade CS33 A EG13 B+ 1.Unnormalized table 2.Repeating groups (list) 3.1NF 4.Determinants and functional dependencies 5.2NF 6.Non-key determinants and functional dependencies 7.3NF in DBDL (with all keys) 1.Unnormalized table 2.Repeating groups (list) 3.1NF 4.Determinants and functional dependencies 5.2NF 6.Non-key determinants and functional dependencies 7.3NF in DBDL (with all keys) Return
The Unnormalized Table n Student (StudentID, StudentLast, StudentFirst, AdvisorID, AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone, CreditsCompleted, ClassStanding, CourseNumber, Grade) – CreditsCompleted is the total credits currently completed by the student – ClassStanding is Freshman, Sophomore, etc. – CourseNumber is each course (of more than one) that the student has taken or is taking Student Transcript
Convert from Unnormalized to 1NF n Identify, list and remove repeating groups n Modify the unnormalized table by including an additional field to create a concatenated primary key Student Transcript
Repeating Groups n CourseNumber, Grade Student Transcript
1NF n Student Grade (StudentID, StudentLast, StudentFirst, AdvisorID, AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone, CreditsCompleted, ClassStanding, CourseNumber, Grade) Student Transcript Return
Convert from 1NF to 2NF n Identify the determinants n List the functional dependencies for each determinant n Create the new tables—one for each determinant and the fields functionally dependent upon it
Determinants n StudentID n CourseNumber n StudentID, CourseNumber 1NF
Determinants and Functional Dependencies n StudentID StudentLast, StudentFirst, AdvisorID, AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone, CreditsCompleted, ClassStanding n CourseNumber n StudentID, CourseNumber Course Grade 1NF Return
2NF n Student (StudentID, StudentLast, StudentFirst, AdvisorID, AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone, CreditsCompleted, ClassStanding n Course (CourseNumber) n Student Course (StudentID, CourseNumber, Grade) Determinants Return
Convert from 2NF to 3NF n Identify any non-key determinants n List the functional dependencies for each non-key determinant n Create any new tables—one for each non- key determinant and the fields functionally dependent upon it
Non-key Determinants n AdvisorID 2NF
Non-key Determinants n AdvisorID AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone 2NF Return
3NF n Student (StudentID, StudentLast, StudentFirst, AdvisorID, CreditsCompleted, ClassStanding n Advisor (AdvisorID, AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone) n Course (CourseNumber) n Student Course (StudentID, CourseNumber, Grade) Return Non-key Determinants
Finalize All Tables in DBDL n Identify all keys, both primary keys and foreign keys
DBDL n Student (StudentID, StudentLast, StudentFirst, AdvisorID, CreditsCompleted, ClassStanding FK AdvisorID Advisor n Advisor (AdvisorID, AdvisorLast, AdvisorFirst, AdvisorOffice, AdvisorPhone n Course (CourseNumber) n Student Course (StudentID, CourseNumber, Grade) FK StudentID Student FK CourseNumber Course 3NF
The Vendor Table
The Product Table
The Purchase Order Table
The Payables Table
The Vendor Data
The Product Data
The Purchase Order Data
The Payables Data Use the mouse to click and place a in the field meaning "Yes" or turn off meaning "No" Use the mouse to click and place a in the field meaning "Yes" or turn off meaning "No"
n List the supplier company, supplier stock number and item name for all products in the inventory data base? n (Linked on common field between tables) select Item, [Supplier stock number], [Company name] from Inventory, Supplier where Inventory.[Supplier code] = Supplier.[Supplier code]; Joining Two Tables Together
select Item, [Supplier stock number], [Company name] from Inventory, Supplier where Inventory.[Supplier code] = Supplier.[Supplier code];
select Item, [Supplier stock number], [Company name] from Inventory, Supplier...;
select Item, [Supplier stock number], [Company name] from Inventory, Supplier where Inventory.[Supplier code] = Supplier.[Supplier code];