1. Logical Database Design and the Relational Model Modern Database Management Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden
2.
3.
4.
5. Figure 5-3 -- Schema for four relations (Pine Valley Furniture) Primary Key Foreign Key (implements 1:N relationship between customer and order) Combined, these are a composite primary key (uniquely identifies the order line)…individually they are foreign keys (implement M:N relationship between order and product)
6.
7.
8. Figure 5-5: Referential integrity constraints (Pine Valley Furniture) Referential integrity constraints are drawn via arrows from dependent to parent table
9.
10. (a) CUSTOMER entity type with simple attributes Figure 5-8: Mapping a regular entity (b) CUSTOMER relation
11. (a) CUSTOMER entity type with composite attribute Figure 5-9: Mapping a composite attribute (b) CUSTOMER relation with address detail
12. Figure 5-10: Mapping a multivalued attribute 1 – to – many relationship between original entity and new relation (a) Multivalued attribute becomes a separate relation with foreign key (b)
15. Figure 5-11(b) Relations resulting from weak entity NOTE: the domain constraint for the foreign key should NOT allow null value if DEPENDENT is a weak entity Foreign key Composite primary key
16.
17. Figure 5-12: Example of mapping a 1:M relationship (a) Relationship between customers and orders Note the mandatory one
18. Figure 5-12(b) Mapping the relationship Again, no null value in the foreign key…this is because of the mandatory minimum cardinality Foreign key
19. Figure 5-13: Example of mapping an M:N relationship (a) ER diagram (M:N) The Supplies relationship will need to become a separate relation
20. Figure 5-13(b) Three resulting relations New intersection relation Foreign key Foreign key Composite primary key
34. Figure 5-21: Mapping Supertype/subtype relationships to relations
35.
36.
37. Example – Figure 5.2b Question – Is this a relation? Answer – Yes: unique rows and no multivalued attributes Question – What’s the primary key? Answer – Composite: Emp_ID, Course_Title
43. Fig 5.23(b) – Functional Dependencies in EMPLOYEE2 Dependency on entire primary key Dependency on only part of the key Therefore, NOT in 2 nd Normal Form!! EmpID CourseTitle DateCompleted Salary DeptName Name EmpID, CourseTitle DateCompleted EmpID Name, DeptName, Salary
44.
45.
46. Figure 5-24 -- Relation with transitive dependency (a) SALES relation with simple data
47. Figure 5-24(b) Relation with transitive dependency CustID Name CustID Salesperson CustID Region All this is OK (2 nd NF) BUT CustID Salesperson Region Transitive dependency (not 3 rd NF)
48. Figure 5.25 -- Removing a transitive dependency (a) Decomposing the SALES relation
49. Figure 5.25(b) Relations in 3NF Now, there are no transitive dependencies… Both relations are in 3 rd NF CustID Name CustID Salesperson Salesperson Region