0% found this document useful (0 votes)
43 views18 pages

5-ER Mapping

Uploaded by

sifelo1382
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views18 pages

5-ER Mapping

Uploaded by

sifelo1382
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Chapter 9

Relational
Database
Design by ER-
and to-
Relational
Mapping

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley


Chapter 9 Outline
▪ Relational Database Design Using ER-to-
Relational Mapping

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Relational Database
Design by ER- and EER-to-
Relational Mapping
▪ Design a relational database schema
▪ Based on a conceptual schema design
▪ Seven-step algorithm to convert the basic
ER model constructs into relations

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Relational Database Design
Using ER-to-Relational Mapping

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


ER-to-Relational Mapping
Algorithm
▪ COMPANY database example
▪ Assume that the mapping will create tables
with simple single-valued attributes
▪ Step 1: Mapping of Regular Entity Types
▪ For each regular entity type, create a relation R
that includes all the simple attributes of E
▪ Called entity relations
• Each tuple represents an entity instance

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


ER-to-Relational Mapping
Algorithm (cont’d.)
▪ Step 2: Mapping of Weak Entity Types
▪ For each weak entity type, create a relation R
and include all simple attributes of the entity
type as attributes of R
▪ Include primary key attribute of owner as
foreign key attributes of R

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Mapping Regular and Weak
Entities

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


ER-to-Relational Mapping
Algorithm (cont’d.)
▪ Step 3: Mapping of Binary 1:1 Relationship
Types
▪ For each binary 1:1 relationship type
• Identify relations that correspond to entity types
participating in R
▪ Possible approaches:
• Foreign key approach
• Merged relationship approach
• Crossreference or relationship relation approach

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


1:1 Mapping: Foreign Key
Approach
SSN Fname Mname Lname Salary Bdate Address

Dnumber Dname

It is better to put in the relation with total


participation the primary key of the other relation
as a foreign key

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


1:1 Mapping: Merged Relation
Approach
SSN Fname Mname Lname Salary Bdate Address

Dnumber Dname

This is possible when both participations are total

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


1:1 Mapping: Cross Reference

SSN Fname Mname Lname Salary Bdate Address

Dnumber Dname

Create new relation containing the two primary key


of the two relations and then choose one of them
to be primary key
Copyright © 2011 Ramez Elmasri and Shamkant Navathe
Mapping 1:M Relationship
▪ Step 4: Mapping of Binary 1:N Relationship
Types
▪ For each regular binary 1:N relationship type
• Identify relation that represents participating entity
type at N-side of relationship type
• Include primary key of other entity type as foreign
key in S
• Include simple attributes of 1:N relationship type as
attributes of S

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Mapping 1:M Relationship
(cont’d.)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Mapping M:N Relationship
▪ Step 5: Mapping of Binary M:N Relationship
Types
▪ For each binary M:N relationship type
• Create a new relation S
• Include primary key of participating entity types as
foreign key attributes in S
• Include any simple attributes of M:N relationship
type

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Mapping M:N Relationship
(cont’d.)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


ER-to-Relational Mapping
Algorithm (cont’d.)
▪ Step 6: Mapping of Multivalued Attributes
▪ For each multivalued attribute
• Create a new relation
• Primary key of R is the combination of A and K
• If the multivalued attribute is composite, include its
simple components

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Copyright © 2011 Ramez Elmasri and Shamkant Navathe
Summary
▪ Map conceptual schema design in the ER
model to a relational database schema
▪ Algorithm for ER-to-relational mapping
▪ Illustrated by examples from the COMPANY
database

Copyright © 2011 Ramez Elmasri and Shamkant Navathe

You might also like