Presentation is loading. Please wait.

Presentation is loading. Please wait.

Quiz 1 1. 2 Where to Store Attributes of Relationship Staff (1) Interviews (0..*) Client Attributes: date, time, comment Staff (StaffNo, …) PK: StaffNo.

Similar presentations


Presentation on theme: "Quiz 1 1. 2 Where to Store Attributes of Relationship Staff (1) Interviews (0..*) Client Attributes: date, time, comment Staff (StaffNo, …) PK: StaffNo."— Presentation transcript:

1 Quiz 1 1

2 2 Where to Store Attributes of Relationship Staff (1) Interviews (0..*) Client Attributes: date, time, comment Staff (StaffNo, …) PK: StaffNo AK: None FK: BranchNo references Branch Client (ClientNo, Name, Address,... InterviewStaffNo, InterviewDate, IntervieTime, InterviewResult) PK: ClientNo AK: None FK: InterviewStaffNo references Staff

3 3 Where to Store Attributes of Relationship E1 (0..1) RelatedTo (1) E2 Attributes: Att1, Att2 E1 (A1, A2, A3, A41, A42, A43, A44, Att1, Att2, B1, B2) PK: A1, A2 AK: None FK: B1, B2 references E2 E2 (B1, B2, B31, B32, B33) PK: B1, B2 AK: None FK: None

4 4 Where to Store Attributes of Relationship Staff (0..*) Inspects (0..*) Car Attributes: date, time, fault Staff (StaffNo,...) Car (CarNo,...) Inspection (ID, StaffNo, CarNo, Date, Time, Fault) PK: ID AK: CarNo, Date, Time StaffNo, Date, Time FK: StaffNo references Staff CarNo references Car

5 5 Complex Relationship (involving 3 or more entities) Client REGESTERS with Staff at Branch Add a new table Registration BranchStaff Client Registers

6 6 Complex Relationship Client REGESTERS with Staff at Branch Add a new table Registration Client RegistrationBranchStaff HasCarryOut Does 1..1 0..* 1..1 0..* 1..1 Is Client the same as Registration?

7 7 Recursive Relationship One-to-Many (1:*) Staff (0..1) Supervises (0..*) Staff (Supervisor) (Supervisee) Add a new column (SupervisorNo) One-to-One (1:1) Add a new column Many-to-Many (*:*) Add a new table

8 8 Superclass/subclass Relationship

9 9 Multiple Relationships between two Entities Staff and Branch Branch (Bno, Street, City, State, Zipcode, Phone) Staff (Sno, firstName, lastName, Address) Branch (1) Has (1..*) Staff Staff (1) Manages (0..1) Branch Cannot have circular references. Branch (Bno, Street, City, State, Zipcode, Phone) Staff (Sno, firstName, lastName, Address, Bno, Position)

10 10 Mapping Weak Entities to Relation Schema Primary Key may not exist Adding PK based on the relationship Combining weak entity into parent entity

11 11 Strong and Weak Entities Staff (Sno, firstName, lastName, Address, Phone, Salary) Next_Of_Kin(firstName, lastName, Address, Phone) Staff (1..*) RelatedTo (0..1) Next_Of_Kin attribute: relationship This is a one-to-many relationship. Create PK for Next_Of_Kin and copy that with attribute relationship to Staff as FK Combine into one table Staff Same person may be Next_Of_Kin of multiple staff members Next_Of_Kin of different staff members are not related

12 12 DBDL (Database Design Language) Branch (Bno, Street, City, State, Zipcode, Phone) PK: Bno AK: Street, City, Zipcode Phone FK: None Staff (Sno, firstName, lastName, Address, Bno ) PK: Sno AK: None FK: Bno references Branch Client (Cno, firstName, lastName, Phone, MaxRent, PrefType) PK: Cno AK: None FK: None Viewing (ID, Rno, Pno, ViewDate, Comment) PK: ID AK: Rno, ViewDate FK: Rno references Client (Cno) Pno references Property No multi-value attributes, no composite attributes. All relationships are maintained through FKs. New attribute ID for Viewing.

13 13 Design Methodology Three main phases 1.Conceptual database design Understanding client data E-R (EER) Model Contract between clients and designers E-R Model could be used for any database system 2.Logical database design Mapping E-R Model to (relational) database schema Normalization 3.Physical database design

14 Assignment4 Due Friday, Beginning of class DropBox UserName_A4 (UserName_A4_2) No UserName_A4_3! 14


Download ppt "Quiz 1 1. 2 Where to Store Attributes of Relationship Staff (1) Interviews (0..*) Client Attributes: date, time, comment Staff (StaffNo, …) PK: StaffNo."

Similar presentations


Ads by Google