Presentation is loading. Please wait.

Presentation is loading. Please wait.

Logical Database Design and Entity-Relationship Mapping “To Err is Human; to Forgive, Divine.” ~ Alexander Pope ~

Similar presentations


Presentation on theme: "Logical Database Design and Entity-Relationship Mapping “To Err is Human; to Forgive, Divine.” ~ Alexander Pope ~"— Presentation transcript:

1 Logical Database Design and Entity-Relationship Mapping “To Err is Human; to Forgive, Divine.” ~ Alexander Pope ~

2 Conceptual vs. Logical CONCEPTUALLOGICAL ERDRelational Diagram EntityRelation (Table) AttributeColumn RelationshipForeign Key (FK) N/APK, Constraints Important: Rows (sample data) MUST be considered in the Logical Model !!!

3 Relational Notation Table or relation is a box. Name of relation is at the top. Columns / Attributes are placed below the relation name in the box. Primary Key columns are Underlined and labeled with PK Foreign Key columns are labeled with FK A PK/FK Relationship between tables are established with an arrow (  ), which always POINTS TO THE PRIMARY KEY of the relationship. SUID PK Lname Fname Ht Wt Students CardNo PK SUID FK CardType ExpDate CreditCards

4 Basic Attribute Mapping Table name is plural Use Naming conventions Assign data types PK for each table Break down composite into simple Set required to not null Set Unique and check constraints Conceptual Logical

5 Mapping 1-M Relationships FK goes on the many side If required on the one side (aka Weak Entity), then set the FK to not allow null Conceptual Logical

6 Mapping Multi-Valued Attributes Similar to 1-M: Place [m] attributes in new table. PK from original table is FK in the new table. Conceptual Logical

7 Mapping Multi-Valued Attributes Similar to 1-M: Place [m] attributes in new table. PK from original table is FK in the new table. Conceptual Logical

8 Mapping 1-1 Relationships Similar to 1-M: Since the FK goes to the optional side of the relationship, but the FK is set to PK. Conceptual Logical

9 Mapping M-M Relationships Conceptual Logical Make a “bridge table” place FKs in bridge table and set as composite PK

10 Mapping Weak Entities Conceptual Logical Make sure the foreign key does not allow null

11

12 Advanced Mapping

13 Ex: Mapping a Unary 1-M Relationship Conceptual Logical EmpID EName Phone HireDate Employee The FK inside the table forms the recursive relationship Manages EmpID PK EName Phone HireDate ManagerEmpID FK Employee

14 Ex: Mapping a Unary N-M Relationship Conceptual Logical ItemNo PK ItmName UnitCost Item Bridge Table with both FK’s relating back to the same table PK Contains ItemNo ItmName UnitCost Item ItemNo PK FK ComponentItemNo PK FK Qty Component

15 Ex: Mapping Sub/Super Type Conceptual Logical EmpNo EName HireDate Employee Discriminator HourlyRate EmpHourly AnnualRate StockOptns EmpSalary EmpNo PK EName HireDate EmpType Employee EmpNo PK FK HourlyRate EmpHourly EmpNo PK FK AnnualRate StockOptns EmpSalary

16 Logical Database Design and Entity-Relationship Mapping Questions?


Download ppt "Logical Database Design and Entity-Relationship Mapping “To Err is Human; to Forgive, Divine.” ~ Alexander Pope ~"

Similar presentations


Ads by Google