MA/Handout 17 -1- Database Systems
Lesson 17
Objectives
Transformation of (E)ER Model into Relational Model
o Attributes
Simple
Composite
Multivalued
o Entities
Regular
Weak
Associative
o Relationship
Unary
One-to-one
One-to-Many
Many-to-Many
Binary
One-to-one
o Minimum/Maximum same on both
o Optional-Mandatory
One-to-Many
Many-to-Many
Ternary
Quaternary
o Super Type
o Subtype
Regular Entities
Regular entities are mapped to relations.
Example
Student
Above entity “Student” will be transformed into Relation
Student (………..)
Attributes
Simple attributes
E-R attributes map directly onto the columns/fields of relation
MA/Handout 17 -2- Database Systems
Example
CUSTOMER relation
In the above example regular entity “Customer” mapped into relation and simple
attributes mapped as fields/columns of relation.
Composite attributes
Use only their simple component (attributes). In other words simple components of
composite will be mapped as fields/columns of relation.
Example
CUSTOMER relation with address detail
In the above example simple components (zip, state, city, street) of custome_address
becomes the columns of relation (cutomer).
Multivalued Attribute
Separate relation will be created for each multivalued attributes with a foreign key
taken from the superior entity.
Example
MA/Handout 17 -3- Database Systems
Multivalued attribute becomes a separate relation
In the above example a separate relation “Employee_Skill” is created for multivalued
“Skill” with foreign key “Employee_ID” from Employee.
Weak Entities
o Becomes a separate relation with a foreign key taken from the superior
entity
o Primary key composed of:
Partial identifier of weak entity
Primary key of identifying relation (strong entity)
Example
MA/Handout 17 -4- Database Systems
Above ER model having week entity “Dependent” will be transformed into relational
as follow.
Composite primary key
In the above example “Dependent” is a weak entity. It is transformed into relation with
foreign key from Employee. Employee also have composite attribute, so simple
components are becomes fields/column.
Associative Entity
Identifier Not Assigned
o Default primary key for the association relation is composed of the
primary keys of the two entities (as in M:N relationship)
Example
MA/Handout 17 -5- Database Systems
In the above example “Order Line” is an associative entity. A separate relation is
created for Order line
o Identifier Assigned
o It is natural and familiar to end-users
o Default identifier may not be unique
MA/Handout 17 -6- Database Systems
Relationship
Unary Relationship
One-to-Many Relationship
Recursive foreign key in the same relation
Example
EMPLOYEE relation with recursive foreign key
Many-to-Many Relationship
MA/Handout 17 -7- Database Systems
ITEM and COMPONENT relations
Binary Relationship
One-to-One Relationship
Primary key on the mandatory side becomes a foreign key on the optional side
Example
One-to-Many Relationship
MA/Handout 17 -8- Database Systems
Primary key on the one side becomes a foreign key on the many side
Foreign key
Many-to-Many Relationship
Create a new relation with the primary keys of the two entities as its primary key
Example
The Supplies relationship will need to become a separ
MA/Handout 17 -9- Database Systems
Composite primary key
Ternary/Quaternary Relationship
One relation for each entity and one for the associative entity
Associative entity has foreign keys to each entity in the relationship
Example
MA/Handout 17 -10- Database Systems
Remember that the primary key MUST be
unique
Mapping Supertype/Subtype Relationships
One relation for supertype and for each subtype
Supertype attributes (including identifier and subtype discriminator) go into
supertype relation
Subtype attributes go into each subtype; primary key of supertype relation also
becomes primary key of subtype relation
1:1 relationship established between supertype and each subtype, with supertype as
primary table
These are implemented as one-to-one
relationships
MA/Handout 17 -11- Database Systems