0% found this document useful (0 votes)
86 views5 pages

Reducing ER-Diagrams To Tables: Tabular Representation of The ER - EER Diagram (EN94)

The document describes the process of converting an ER diagram into relational tables. It involves 7 steps: 1) Create a table for each entity containing its attributes. Choose a primary key. 2) Create tables for weak entities containing owner keys as foreign keys. 3) Add owner keys as foreign keys to tables for 1:1 relationships. 4) Add participating key as foreign key for tables on the N-side of 1:N relationships. 5) Create tables for M:N relationships containing foreign keys to participating entities. 6) Create tables for multivalued attributes containing foreign keys. 7) Create tables for n-ary relationships containing foreign keys to participating entities.

Uploaded by

Rajinder Sanwal
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)
86 views5 pages

Reducing ER-Diagrams To Tables: Tabular Representation of The ER - EER Diagram (EN94)

The document describes the process of converting an ER diagram into relational tables. It involves 7 steps: 1) Create a table for each entity containing its attributes. Choose a primary key. 2) Create tables for weak entities containing owner keys as foreign keys. 3) Add owner keys as foreign keys to tables for 1:1 relationships. 4) Add participating key as foreign key for tables on the N-side of 1:N relationships. 5) Create tables for M:N relationships containing foreign keys to participating entities. 6) Create tables for multivalued attributes containing foreign keys. 7) Create tables for n-ary relationships containing foreign keys to participating entities.

Uploaded by

Rajinder Sanwal
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/ 5

1

Reducing ER-Diagrams to Tables


Problem: Consider the entities of Project,
General Task and Employee in a project
management or job shop organization.
Specify the relations with typical attributes
to represent these entities and the
relationships between them. [MH91]
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
COMPANY DATABSE
DEPARTMENT
Number
Name
Location
Works_For
N
1
Manages
StartDate
1 1
Supervision
1
supervisee
supervisor
N
Dependents
EMP_DEP
Bdate
Name
Sex
Relationship
N
1
PROJECT
Name
Number
Location
Works_On
Hours
CONTROLS
N N
1
M
Dependents
Bdate
DeName
Sex
Relationship
PROJECT
Name
PNo
Location
Dependents-Of
Works_On
Hours
N
M
N
1
N
Supervision
CONTROLS
Manages
StartDate
COMPANY DATABSE
1 N
1
1
Works_For
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
N
DEPARTMENT
DNo
DName
DLocation
1
1
Tabular Representation of the
ER EER Diagram [EN94]
STEP 1:
For each regular entity type E in the ER schema,
create a relation R that includes all the simple
attributes of E.
Include only the simple component attributes of a
composite attribute.
Choose one of the key attributes of E as primary
key for R.
If the chosen key of E is composite, the set of simple
attributes that form it will together from the primary
key of R.
Dependents
Bdate
DeName
Sex
Relationship
PROJECT
Name
PNo
Location
Dependents-Of
Works_On
Hours
N
M
N
1
N
Supervision
CONTROLS
Manages
StartDate
COMPANY DATABSE
1 N
1
1
Works_For
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
N
DEPARTMENT
DNo
DName
DLocation
1
1
2
EMPLOYEE
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
FName
MI
LName
Manila 1950/02/02 12000 F Maria B. Santos 02
Makati 1960/01/01 10000 M Juan A. Cruz 01
Address Bdate Salary Sex LName MI FName SSN
Primary key
Dependents
Bdate
DeName
Sex
Relationship
PROJECT
Name
PNo
Location
Dependents-Of
Works_On
Hours
N
M
N
1
N
Supervision
CONTROLS
Manages
StartDate
COMPANY DATABSE
1 N
1
1
Works_For
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
N
DEPARTMENT
DNo
DName
DLocation
1
1
DEPARTMENT
DNo
Name
Location
Name DNo
Primary Key
Multi-valued attribute
Dependents
Bdate
DeName
Sex
Relationship
PROJECT
Name
PNo
Location
Dependents-Of
Works_On
Hours
N
M
N
1
N
Supervision
CONTROLS
Manages
StartDate
COMPANY DATABSE
1 N
1
1
Works_For
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
N
DEPARTMENT
DNo
DName
DLocation
1
1
Location Name PNo
PROJECT
Name
PNo
Location
Primary Key
STEP 2:
For each weak entity type Win the ER schema with
owner entity type E, create a relation R and include all
simple attributes (or simple components of composite
attributes) of W as attributes of R.
In addition, include as foreign key attributes of R
the primary key attributes(s) of the relation(s) that
correspond to the owner entity type(s). This handles
the identifying relationship type of W.
The primary key of R is the combination of the
primary key(s) of the owner(s) and the partial key of
the weak entity type W, if any.
3
Dependents
Bdate
DeName
Sex
Relationship
PROJECT
Name
PNo
Location
Dependents-Of
Works_On
Hours
N
M
N
1
N
Supervision
CONTROLS
Manages
StartDate
COMPANY DATABSE
1 N
1
1
Works_For
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
N
DEPARTMENT
DNo
DName
DLocation
1
1
DEPENDENTS
Son 1990/04/04 M Jun Santos 02
Mother 1940/03/01 F Clara Cruz 01
Relationship Bdate Sex DeName ESSN
Foreign key
Dependents
Bdate
Sex
Relationship
DeName
Primary key
STEP 3:
For each binary 1:1 relationship type R in the
ER schema, identify the relations S and T that
correspond to the entity types participating in
R.
Choose one of the relations (let say S) and
include as foreign key in S the primary key
of T. It is better to choose an entity type with
total participation in R in the role of S.
Include the entire simple attributes (or simple
components of composite attributes) of the 1:1
relationship type R as attributes of S.
Dependents
Bdate
DeName
Sex
Relationship
PROJECT
Name
PNo
Location
Dependents-Of
Works_On
Hours
N
M
N
1
N
Supervision
CONTROLS
Manages
StartDate
COMPANY DATABSE
1 N
1
1
Works_For
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
N
DEPARTMENT
DNo
DName
DLocation
1
1
MANAGES
Finance
Personnel
Name
02
01
MGRSSN
1992/06/06
1990/05/05
StartDate
D2
D3
DNo
Manages
StartDate
1 1
DEPARTMENT
DNo
Name
Location
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
Name DNo
Primary key
STEP 4:
For each regular (non-weak) binary 1:N
relationship type R, identify the relation S that
represents the participating entity type at the N-side of
the relationship type.
Include as foreign key in S the primary key of the
relation T that represents the other entity type
participating in R*.
Include any simple attributes (or simple components
of composite attributes) of the 1:N relationship type as
attributes of S.
*** The reason for this is that each entity instance on the N-side is
related to at most one entity instance on the 1-side of the
relationship type.
4
Dependents
Bdate
DeName
Sex
Relationship
PROJECT
Name
PNo
Location
Dependents-Of
Works_On
Hours
N
M
N
1
N
Supervision
CONTROLS
Manages
StartDate
COMPANY DATABSE
1 N
1
1
Works_For
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
N
DEPARTMENT
DNo
DName
DLocation
1
1
EMPLOYEE
DEPARTMENT
DNo
DName
Location
Works_For
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
N
1
Manila
Makati
Address
D2 1950/02/02 12000 F Maria B. Santos 02
D1 1960/01/01 10000 M Juan A. Cruz 01
DNo Bdate Salary Sex LName M
I
FName SSN
Manila 1950/02/02 12000 F Maria B. Santos 02
Makati 1960/01/01 10000 M Juan A. Cruz 01
Address Bdate Salary Sex LName MI FName SSN
Primary key
STEP 5:
For each binary M:N relationship type R,
create a new relation S to represent R.
Include as foreign key attributes in S the
primary keys of the relations that represent the
participating entity types; their combination
will form the primary key of S.
Also include any simple attributes of the M:N
relationship (or simple components of
composite attributes) as attributes of S.
Dependents
Bdate
DeName
Sex
Relationship
PROJECT
Name
PNo
Location
Dependents-Of
Works_On
Hours
N
M
N
1
N
Supervision
CONTROLS
Manages
StartDate
COMPANY DATABSE
1 N
1
1
Works_For
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
N
DEPARTMENT
DNo
DName
DLocation
1
1
WORKS_ON
30 P1 02
20 P1 01
Hours PNo ESSN
Works_On
Hours
M
N
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
PROJECT
Name
PNo Location
Primary key
STEP 6:
For each multivalued attribute A, create a
new relation R that includes an attribute
corresponding to A.
Include the primary key attribute K (as a
foreign key in R) of the relation that represents
the entity type or relationship type that has A
as an attribute.
The primary key of R is the combination of A
and K. If the multivalued attribute is
composite, include its simple components.
5
Dependents
Bdate
DeName
Sex
Relationship
PROJECT
Name
PNo
Location
Dependents-Of
Works_On
Hours
N
M
N
1
N
Supervision
CONTROLS
Manages
StartDate
COMPANY DATABSE
1 N
1
1
Works_For
EMPLOYEE
SSN
Bdate
Name
Sex
Address
Salary
N
DEPARTMENT
DNo
DName
DLocation
1
1
DEPT_LOCATION
Loc2 D1
Loc1 D2
Loc3 D2
Loc1 D1
DLocation DNo
DEPARTMENT
DNo
Name
DLocation
Primary key
EMPLOYEE(SSN,FName,MI,Lname,Sex,
Salary,Bdate, Address, SUPERSSN,DNo)
DEPARTMENT(DNumber,DName,MGRSSN,
StartDate)
DEPT_LOCATION(DNo, Location)
PROJECT(PNo, PName, Plocation,DNum)
WORKS_ON(ESSN,PNo, Hours)
DEPENDENT(ESSN, DependentName, Sex,
Bdate, Relationship)
TABLES as RELATIONS STEP 7:
For each n-ary relationship type R, n>2, create a new
relation S to represent R.
Include as foreign key attributes in S the primary keys
of the relations that represent the participating entity
types.
Also, include any simple attributes of the n-ary
relationship type (or simple components of composite
attributes) as attributes of S.
The primary key of S is usually a combination of all
the foreign keys that reference the relations
representing the participating entity types.
However if the participation is constraint (min,
max) of one of the entity types E participating
in R has max = 1, then the primary key of S
can be the single foreign key attribute that
references the relation E corresponding to E.
This is because in this case, each entity e in E
will participate in at most one relationship
instance of R and hence can uniquely identify
that relationship instance.
SUPPLY
Part2
Part1
PartNo
30
20
Quantity
P1 B
P1 A
PNo SName
SUPPLY
Quantity
SUPPLIER
SName
PROJECT
PNo
PART
PartNo
Primary key
M
M
M

You might also like