Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.

Similar presentations


Presentation on theme: "1 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key."— Presentation transcript:

1 1 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key

2 2 Candidate Key A minimum set of attributes that uniquely identifies each occurrence of an entity type. No proper subset satisfying the definition. Not minimum cardinality. R (Att1, Att2, Att3) Candidate Key: (Att1, Att2) Either Att1 or Att2 is not a candidate key But Att3 could be a candidate key An entity type could have more than one candidate key. Attributes of a candidate key cannot have null values.

3 3 Examples List the candidate keys for each table Branch (branchNo, street, city, state, zipcode) Owner (ownerNo, fName, lName, address, telNo) Viewing (clientNo, propertyNo, viewDate, comment)

4 4 Primary/Alternate Key Primary Key (PK) The candidate key that is selected to uniquely identify each occurrence of an entity type. Alternate key (AK) candidate key, but not primary key One entity type one PK zero or more AKs

5 5 Primary/Alternate Key Branch (branchNo, street, city, state, zipcode) PK: branchNo AK: street, city, zipcode Owner (ownerNo, fName, lName, address, telNo) PK: ownerNo AK: None Viewing (clientNo, propertyNo, viewDate, comment) PK: clientNo, viewDate AK: None

6 6 Simple and Composite Key Branch (branchNo, street, city, state, zipcode) Simple Owner (ownerNo, fName, lName, address, telNo) Simple Viewing (clientNo, propertyNo, viewDate, comment) Composite

7 7 Example Table Schema R (A, B, C) Table Instance A B C 100 x ct 200 y se 200 x cis Any candidate keys? Business rules. Part of table schema. Cannot be decided based on table instance only.

8 8 Diagrammatic Representation of Attributes Branch branchNo {PK} address … Branch branchNo Branch branchNo address … Only show the PKs in ER diagram.

9 9 Strong and Weak Entity Strong Entity not existence-dependent on other entity Weak Entity existence-dependent on other entity Business rules!

10 10 Strong and Weak Entity Patient patientNo name … Next_Of_Kin name phone … Has Strong entity Must have PK Parent Owner Dominant Weak entity May not have PK Child Dependent Subordinate

11 11 Structural Constraints Business Rules Participation Total (Mandatory) Partial (Optional) Cardinality Max number of occurrences that can be related to one occurrence Staff Oversees PropertyForRent

12 12 Structural Constraints: Multiplicity Combination of Participation and Cardinality Multiplicity of Binary Relationship one-to-one one-to-many many-to-many

13 13 Multiplicity: one-to-one Staff staffNo Branch branchNo Staff (1..1) Manages (0..1) Branch 1..1 0..1 Each branch has exactly one manager. Each staff manages zero or one branch. For one object on the other side! Manages

14 14 Multiplicity: one-to-many Staff staffNo PropertyForRent propertyNo Staff (0..1) Oversees (0..*) PropertyForRent 0..1 0..* For one object on the other side! One property is managed by 0 or 1 staff One staff manages 0 or more properties

15 15 Multiplicity: many-to-many NewsPaper newspaperName PropertyForRent propertyNo NewsPaper (0..*) Advertises (1..*) PropertyForRent 0..* 1..* For one object on the other side! One property is advertised on 1 or more newspapers One newspaper has Ads for 1 or more properties

16 16 Structural Constraints: Multiplicity Multiplicity of Complex Relationship (n-ary) When (n-1) values are fixed for other entities

17 17 Multiplicity for Complex Relationship BranchStaff Client Registers 0..* 0..1 Client (0..*) Registers with Staff (0..1) at Branch (0..1)


Download ppt "1 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key."

Similar presentations


Ads by Google