0% found this document useful (0 votes)
15 views

W2 Topic3 RelationalDatabaseDesign 2021

Uploaded by

pokemon5916
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

W2 Topic3 RelationalDatabaseDesign 2021

Uploaded by

pokemon5916
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

CSE2DBF – CSE4DBF

Relational Database Design (Top Down)

Reading:
Elmasri and Navathe, “Fundamentals of Database Systems, Chapters 1 & 2”, Pearson, 2016.
Ebook: https://ebookcentral-proquest-
com.ez.library.latrobe.edu.au/lib/latrobe/detail.action?docID=5573709
Relational Database Design

Two Approaches in Relational Database Design

• From Data Modeling ( eg. ER Model ) to Relational Logical Model


for implementation.

TOP DOWN DESIGN

• Normalization of Relations

BOTTOM UP DESIGN

Today’s lecture looks at top-down design, bottom-up design will be


described in Topic 4.
Relational Database Design
Consider the following ER-Diagram
deptNo

deptName
1 (0, 1) 1 (1, 1)
empNo
Employee manages Department
name
1 (0, m) M (1, m) M (1, 1) 1 (1, m)
address

degree works on works for


has
projNo
M (1, 1) M (1, m)
projName
Project
Dependent
M (0, m)
quantity partNo
dependentName date

dateOfBirth supplies partName


M (1, m) M (1, m)

Supplier Part
supNo

supName
Transformation of E-R Model into Relational Logical
Model (Top Down design)

• E-R to Relational Mapping Algorithm will be explained here


step by step.
STEP 1: For each regular entity in the ER model, create a relation (i.e a
table that includes all the simple attributes). Make sure to identify the
primary key for the relation (i.e the PK of the entity).

Note: if there is a specialization/generalization relationship in your EER (to


be discussed in Topic 3 – Part 2, you need to transform the ‘superclass’
entity only within this Step 1).

Taking the ER-Diagram on the previous slide as an example:

EMPLOYEE (empNo, name, address)


DEPARTMENT(deptNo, deptName)
PROJECT(projNo, projTitle)
SUPPLIER(supNo, supName)
PART(partNo, partName)
Transformation of E-R Model into Relational Logical
Model (Top Down design)

STEP 2: For each weak entity in the ER model, create a relation which
includes all the simple attributes. The primary key of the relation is the
combination of the primary key/s of the ‘owner’ and the key of the weak entity
itself.

empNo
Employee
name
1 (0, m)
address

degree
has

M (1, 1)

Dependent DEPENDENT
(empNo, dependentName, dateOfBirth)
dependentName

dateOfBirth
Transformation of E-R Model into Relational Logical
Model (Top Down design)

STEP 3: For each binary 1 TO 1 Relationship identify the two relations that
correspond to the entities participating in the relationship. Choose one of
the Relation (usually the one with total participation) and include as foreign
key the primary key of the other relation.

deptNo

deptName
1 (0, 1) 1 (1, 1)
empNo
Employee manages Department
name

address

degree

DEPARTMENT( deptNo, deptName, mngrEmpNo)


Transformation of E-R Model into Relational Logical
Model (Top Down design)

STEP 4: For each binary 1 TO N Relationship identify the relations that


represent the participating entity at the N (i.e many) side of the relationship.
Include as foreign key in the relation that holds the N side, the primary key
of the other entity (that holds the 1 side).
deptNo

deptName

empNo
Employee Department
name
M (1, 1) 1 (1, m)
address

degree works for

EMPLOYEE (empNo, name, address, deptNo)


Transformation of E-R Model into Relational Logical
Model (Top Down design)

STEP 5: For each binary M:N Relationship create a new relation to represent
the relationship. The primary key of the new relation is the combination of
the primary keys of the two connected entities.

empNo
Employee
name
M (1, m)
address

degree works on
projNo
M (1, m)
projName
Project

WORKS ON (empNo, projNo)


Transformation of E-R Model into Relational Logical
Model (Top Down design)

STEP 6: For each multivalued attribute, create a new relation that includes
the multivalued attribute and the primary key of the entity where the
multivalued attribute is attached.

empNo
Employee
name

address

degree EMPLOYEE (empNo, name, address, deptNo)


EDEGREE(empNo, degree)
Transformation of E-R Model into Relational Logical
Model (Top Down design)

STEP 7: For each n-ary ( > 2 ) Relationship create a new relation to represent
the relationship. The primary key of the new relation is the combination of the
primary keys of the participating entities that hold the N (many) side. In most
cases of an n-ary relationship all the participating entities hold a many side.

projNo

projName
Project
M (0, m)
quantity partNo
date

supplies partName
M (1, m) M (1, m)

Supplier Part
supNo

supName

SUPPLIES (supNo , projNo, partNo , date, quantity)


Transformation of E-R Model into Relational Logical
Model (Top Down design)

FINAL TABLES

PROJECT(projNo, projTitle)
SUPPLIER(supNo, supName)
PART(partNo, partName)
DEPENDENT( empNo, dependentName, dateOfBirth)
DEPARTMENT( deptNo, deptName, mngrEmpNo)
EMPLOYEE (empNo, name, address, deptNo)
WORKS ON (empNo, projNo)
EDEGREE(empNo, degree)
SUPPLIES (supNo , projNo, partNo, date, quantity)
Relational Database Design
Perform the complete transformation steps for the E-R Model
of the ‘Real Estate Agency’ described in Topic 2.

SOLUTION: (to be discussed in the lecture)


Next Lecture

EER Modelling and Transformation

Reading:
Elmasri and Navathe, “Fundamentals of Database Systems, Chapters 1 & 2”, Pearson, 2016.
Ebook: https://ebookcentral-proquest-
com.ez.library.latrobe.edu.au/lib/latrobe/detail.action?docID=5573709

You might also like