7
Overview/Review of DB Logical Design ER Model to Relational Model Mapping

Overview/Review of DB Logical Design

Embed Size (px)

DESCRIPTION

Overview/Review of DB Logical Design. ER Model to Relational Model Mapping. Transforming ER into RDB. ER. RDB. attr. attr. table. relationships. table. table. entities. Transforming ER into RDB (2). Make a relation for each entity Unique identifier of entity becomes key of relation - PowerPoint PPT Presentation

Citation preview

Page 1: Overview/Review of DB Logical Design

Overview/Review of DB Logical Design

ER Model to Relational Model Mapping

Page 2: Overview/Review of DB Logical Design

Transforming ER into RDB

attr attr

relationships

entities

table

table

table

ER RDB

Page 3: Overview/Review of DB Logical Design

Transforming ER into RDB (2)

Make a relation for each entity Unique identifier of entity becomes key of

relation Attributes of entity becomes attributes of

relation For each 1 - M relationship:

Take the primary key of the 1-side entity and place it as a foreign key in the M-side entity relation

Page 4: Overview/Review of DB Logical Design

Transforming ER into RDB (3)

1 - 1 relationships can be mapped similarly when compared to 1 - M’s Where do you house the foreign key?

Make a relation for each M - M relationship Attributes of relation

Attributes of relationship + key of each entity Primary key of relation

Unique identifier of each entity {+ attribute of relationship}

Page 5: Overview/Review of DB Logical Design

Transforming ER into RDB (4)

Example:

Staff (StaffNo, Address, …)Branch (BranchNo, TelNo, …)Property (PropNo, Rent, …, StaffNo, BranchNo)IsAllocated (StaffNo, BranchNo, Percent)

Staff

IsAllocated

Branch

Oversees

PropertyHas

StaffNo

PropNoBranchNo

M

M1 M

M

1

Rent

Address

Percent

TelNo

Note: Underline attributes arePKs and italics are FKs; an attributecan be both PK and FK

Page 6: Overview/Review of DB Logical Design

Transforming ER into RDB (5)

Sometimes a 1 - M relationship should be mapped into a separate relation

E.g.,Employee (Emp#, …)

Car (Car#, …)

IsAssigned (Emp#, …., Car#)

Emp#

Car#

IsAssignedEmployee CarM 1

Page 7: Overview/Review of DB Logical Design

ER to Relational: Exercise

Owns

Car

MarriedTo

AccidentLogs

License#VIN

M

M1 M

1

Damage $

Person

SS#

model

Spouse

SS#

1

Age