0% found this document useful (0 votes)
101 views27 pages

Database Systems: Transforming ERD To Rela7ons

Uploaded by

Obaid Rehman
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)
101 views27 pages

Database Systems: Transforming ERD To Rela7ons

Uploaded by

Obaid Rehman
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/ 27

DATABASE

SYSTEMS
Transforming ERD to Rela7ons

Dr. Khalid La,f
Transforming ERD to Rela7ons
This can be done automa,cally by many CASE tools,
but it is important to understand the process
CASE tools o?en cannot model complex data

rela,onships such as ternary rela,onships.


For these situa,ons you may have to perform these steps
manually.
Some,mes alterna,ve solu,ons exist, and you must
choose the best
You must be able to quality check the CASE tool

results

2
Transforma7on Steps
Step 1: Map Regular En,,es
Step 2: Map Weak En,,es

Step 3: Map Binary Rela,onships

One to Many, Many to Many, One to One

Step 4: Map Associa,ve En,,es


Step 5: Map Unary Rela,onships

One to Many, and Many to Many

Step 6: Map Ternary (n-ary) Rela,onships

3
Step1: Mapping a Regular En7ty
Simple a?ributes: map directly onto the rela,on

(a) CUSTOMER
en7ty type with
simple a?ributes

(b) CUSTOMER rela7on

4
Mapping a Composite A?ribute
Composite a?ributes: Only keep their cons,tuents

(a) CUSTOMER
en,ty type with
composite
aXribute

(b) CUSTOMER rela,on with address detail

5
Handling Mul7valued A?ributes

AXribute becomes part of a composite primary key


in the new en,ty
Primary key of the main en,ty is included in the

new en,ty as part of the composite key

6
Step 2: Mapping Weak En77es
Becomes a separate rela,on with a foreign
key taken from the iden,fying owner
Primary key composed of:

Par,al iden,er of weak en,ty


Primary key of iden,fying rela,on (strong en,ty)

7
Example of mapping a weak en7ty
a) Dependent rela,on

8
Example of mapping a weak en7ty
b) Rela,ons resul,ng from weak en,ty

EMPLOYEE
Employee_ID Employee_Name

The domain constraint for


Foreign key the foreign key should
NOT allow null value
DEPENDENT
Dependent_Name Employee_ID Date_of_Birth Gender

Composite primary key

9
Mul7valued A?ributes in Regular En77es
AXributes are atomic in database systems
Mul7valued a?ribute becomes a separate rela,on
with a foreign key taken from the original en,ty
Same as for weak en,,es

Employee
EID Name

Skills
EID Skill
Onetomany rela7onship between original en7ty
and new rela7on
10
Composite Mul7valued A?ributes
The composi,on could be converted into a
separate en,ty with a many-to-many
rela,onship.

Converted to

11
Step3: Binary One-to-One Rela7onships
Primary key on the mandatory side becomes a
foreign key on the op7onal side

AXributes of
the rela,onship
also go to the
op,ons side.

12
Step3: Binary One-to-Many Rela7onships
Primary key on the one side becomes a
foreign key on the many side

Note the mandatory one

Foreign key Set foreign key to be


NOT NULL for mandatory
minimum cardinality
13
Example of data for 1:M rela7onship
Customer
Customer ID Customer_Name Customer_Address
101 Ali Blue Area
102 Omer Jinnah Super
103 Usman Aabpara

Order
Order ID Order Date Customer ID
1001 20-Jun-2009 101
1002 21-Jun-2009 102
1003 21-Jun-2009 101
1004 22-Jun-2009 103

14
Step3: Binary Many-Many Rela7onships
Create a new rela,on with the primary keys
of the two en,,es as its primary key
Date_Completed

The Completes rela,onship will need to become a


separate rela,on
15
Example of mapping an M:N rela7onship

Composite primary key

New
intersec,on
Foreign key
rela,on
Foreign key

16
Step4: Mapping Associa7ve En77es
Iden,er Assigned

Foreign keys are not part of primary key

17
Associa7ve En7ty without Iden7er
Iden,er NOT Assigned

Composite primary key formed from the two foreign keys


18
Step5: Mapping Unary Rela7onships
One-to-Many Recursive foreign key in the same
rela,on
(a) EMPLOYEE
en,ty with
unary
rela,onship

(b) EMPLOYEE rela,on with recursive foreign key

19
Example Data for Unary 1:N Rela7onship
Employee and Manager

Employee ID Employee_Name Date_of_Birth Manager ID


101 Ali 01-Jan-1977 NULL
102 Omer 01-Jan-1978 101
103 Usman 01-Jan-1979 101
104 Fa,ma 01-Jan-1980 101
105 Hasan 01-Jan-1981 104
106 Abdullah 01-Jan-1982 102

20
Step5: Mapping Unary Rela7onships
Many-to-Many leads to two rela,ons:
The original en,ty
New associa,ve rela,on in which the primary
key has two aXributes, both taken from the
primary key of the original en,ty

21
Mapping a Unary M:N Rela7onship

Contains
(a) Bill-of-materials
Quan,ty rela,onships (M:N)

(b) ITEM and


COMPONENT
rela,ons

22
Bill-of-Material Sample Data
Item
Item No Descrip7on Unit_Cost
101 Glass Dining Table 20,000
102 Glass 12mm 3x5 5,000
103 Wooden Pillar 1x1x2 4,000
104 Oce Table 15,000

Components
Item No Component No Quan7ty
101 102 1
101 103 2
104 102 1

23
Step6: Mapping Ternary Rela7onships
One rela,on for each en,ty and one for the associa,ve
en,ty
Associa,ve en,ty has foreign keys to each en,ty in the
rela,onship

24
Ternary Rela7onship Mapping Example

Vendor Part Warehouse


VID PID WID

VID PID WID ShippingMode UnitCost


SupplySchedule

25
Transform ERD to Rela7onal Schema

26
Conclusion
Logical database model is the process of
transforming the conceptual model into
logical data model.

Logical Database Design Process


Part 1: Transforming E-R to Rela,onal Model

27

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy