0% found this document useful (0 votes)
84 views15 pages

Lecture 03 Transformation of Erd To Rdbms

The document describes the process of transforming an entity-relationship (ER) diagram into a relational database schema. It involves turning entity sets into tables, relationships into foreign keys, and establishing rules based on cardinality and participation. Several examples are provided of applying the rules to transform an ER diagram with employees, departments, and projects into related tables with the appropriate attributes and foreign key constraints.
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)
84 views15 pages

Lecture 03 Transformation of Erd To Rdbms

The document describes the process of transforming an entity-relationship (ER) diagram into a relational database schema. It involves turning entity sets into tables, relationships into foreign keys, and establishing rules based on cardinality and participation. Several examples are provided of applying the rules to transform an ER diagram with employees, departments, and projects into related tables with the appropriate attributes and foreign key constraints.
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/ 15

Transformation from

ER to Relational Model
Transformation
 Involves the transformation of the ER diagram to a complete
database scheme
 Entity set in the ER model become tables in a relational
database
 The relationships become the source of foreign keys that
integrate the resulting table together
 Based on the mapping cardinalities & entity participation of
the relationship

MIS 106 Advance Data Management


Given
 Let:
 E1 and E2 be entity sets
 R be a relationship that associates E1 & E2
 ER Diagram:

hours
deptname
empid
deptid
name

employee works department

MIS 106 Advance Data Management


Rule 1
 many-to-many regardless of entity participation

hours
deptname
empid
name deptid

employee works department

Employee(empid,name)
department(deptid,deptname)
works(empid,deptid,hours)

MIS 106 Advance Data Management


Rule 2
 One-to-many, mandatory on the many side regardless of
entity participation on the “1” side

hours
deptname
empid
deptid
name

employee works department

Employee(empid,name)
department(deptid,deptname)
MIS 106 Advance Data Management
Rule 3
 One-to-many, optional on the many side regardless of entity
participation on the “1” side

hours
deptname
empid
name deptid

employee works department

Employee(empid,name)
department(deptid,deptname)
works(empid,deptid,hours)
MIS 106

Advance Data Management


Rule 4
 One-to-one, mandatory on both sides

hours
deptname
empid
deptid
name

employee works department

Employee(empid,name, hours) Employee(empid,name)


department(deptid,deptname) or
department(deptid,deptname,hours)

MIS 106 Advance Data Management


Rule 5
 One-to-one, mandatory on one side

hours
deptname
empid
deptid
name

employee works department

Employee(empid,name, hours)
department(deptid,deptname)

MIS 106 Advance Data Management


Rule 6
 Optional on both sides

hours
deptname
empid
deptid
name

employee works department

Employee(empid,name)
department(deptid,deptname)
works(empid,deptid,hours)
MIS 106 Advance Data Management
Transform the ER Diagram into a
Relational Schema
deptid deptname

works for
DEPARTMENT
empid

name
manages
EMPLOYEE
address

bdate
projid
works on
PROJECT
projname

hours

MIS 106 Advance Data Management


Two entities at a time
empid

name projid
works on
EMPLOYEE PROJECT
address projname

hours
bdate

Apply Rule 1: many-to-many, regardless of entity participation

EMPLOYEE(empid,name,address,bdate)
PROJECT(projid,projname)
WORKS(empid,projid,hours)
MIS 106
Next
empid

deptid
name
works for
EMPLOYEE DEPARTMENT
deptname
address

bdate

Apply Rule 2: one-to-many, mandatory on the “many” side

EMPLOYEE(empid,name,address,bdate,deptid)
DEPARTMENT(deptid,deptname)

MIS 106 Advance Data Management


And the last…
empid

deptid
name
manages
EMPLOYEE DEPARTMENT
deptname
address

bdate

Apply Rule 5: one-to-one, mandatory on the one side

EMPLOYEE(empid,name,address,bdate)
DEPARTMENT(deptid,deptname,empid)

MIS 106 Advance Data Management


The Complete Relational Schema
EMPLOYEE(empid,name,address,bdate,
deptid)
PROJECT(projid,projname)
DEPARTMENT(deptid,deptname,empid)
WORKS(empid,projid,hours)

MIS 106 Advance Data Management


End of Lecture

Any question?

You might also like