8 Mapping ERD To Relations
8 Mapping ERD To Relations
ZICTC@2019 1
Mapping Algorithm
ZICTC@2019 2
Mapping Regular Entities
• Each regular entity type in an ER diagram is
transformed into a relation.
• The name given to the relation is generally
the same as the entity type.
• Each simple attribute of the entity type
becomes an attribute of the relation.
• The identifier of the entity type becomes the
primary key of the corresponding
• relation.
ZICTC@2019 3
PLAYER
ZICTC@2019 4
Converting Composite Attribute in
an ER Diagram to Relations
ZICTC@2019 5
Mapping Multivalued Attributes in
ER Diagram to Relations
• In this example, the skill associated with the
EMPLOYEE is a multivalued attribute, since
an EMPLOYEE can have more than one
skill as fitter, electrician,turner, etc.
ZICTC@2019 6
ZICTC@2019 7
Converting “Weak Entities” in ER
Diagram to Relations
• For each weak entity type, create a new relation
and include all of the simple attributes as attributes
of the relation.
• Then include the primary key of the identifying
relation as a foreign key attribute to this new
relation.
• The primary key of the new relation is the
combination of the primary key of the identifying
and the partial identifier of the weak entity type.
ZICTC@2019 8
ZICTC@2019 9
Converting Binary Relationship to
Relation
• A relationship which involves two entities
can be termed as binary relationship.
• This binary relationship can be one-to-one,
one-to-many, many-to-one, and many-to-
many.
ZICTC@2019 10
Mapping one-to-Many Relationship
• For each 1–M relationship, first create a
relation for each of the two entity type’s
participation in the relationship.
ZICTC@2019 11
ZICTC@2019 12
• Binary one-to-one relationship can be
viewed as a special case of one-to-many
relationships.
• The process of mapping one-to-one
relationship requires two steps.
• First, two relations are created, one for each
of the participating entity types.
• Second, the primary key of one of the
relations is included as a foreign key in the
other relation.
ZICTC@2019 13
Mapping Associative Entity to
Relations
• Many-to-many relationship can be modeled
as an associative entity in the ER diagram.
ZICTC@2019 14
Without Identifier
ZICTC@2019 15
ZICTC@2019 16
With Identifier
ZICTC@2019 17
ZICTC@2019 18
ZICTC@2019 19
Converting Unary Relationship to
Relations
• Unary relationships are also called recursive
relationships.
• The two most important cases of unary
relationship are one-to-many and many-to-
many.
ZICTC@2019 20
One-to-many Unary Relationship
ZICTC@2019 21
ZICTC@2019 22
Converting Ternary Relationship to
Relations
• A ternary relationship is a relationship
among three entity types.
• The three entities given in this example are
PATIENT, PHYSICIAN, and TREATMENT.
• The PATIENT–TREATMENT is an
associative entity.
ZICTC@2019 23
ZICTC@2019 24
ZICTC@2019 25
Example – N-ary Relationship Set
ZICTC@2019 26
Converting EERD to Relational
ZICTC@2019 27
disjoint optional
ZICTC@2019 28
Step 3a Results
ZICTC@2019 29
Step 3b:
ZICTC@2019 30
disjoint mandatory
• EG
EMPLOYEE
SALARIED- HOURLY-
EMPLOYEEE EMPLOYEE
ZICTC@2019 31
Step 3b Results
ZICTC@2019 32
Step 3c:
ZICTC@2019 33
Overlapping Optional
ZICTC@2019 34
overlapping optional
• EG
EMPLOYEE
ZICTC@2019 35
Step 3c Result
ZICTC@2019 36
Step 3d
ZICTC@2019 37
Step 3d cont:
ZICTC@2019 38
overlapping mandatory
ZICTC@2019 39
overlapping mandatory
PART
MANUFACTURED PURCHASED
PART PART
ZICTC@2019 40
Step 3d Result
ZICTC@2019 41
ZICTC@2019 42
ZICTC@2019 43
Question:
• RTSA administers driving tests and issues
driver’s licenses. Any person who wants a
driver’s license must first take a learner’s
exam at any RTSA Branch in the province.
• If he/she fails the exam, he can take the
exam again any time after a week of the
failed exam date, at any branch. If he
passes the exam, he is issued a license
(type = learner’s) with a unique license
number.
ZICTC@2019 44
• A learner’s license may contain a single
restriction on it. The person may take his
driver’s exam at any RTSA branch any
time before the learner’s license expiry
date (which is usually set at six months
after the license issue date).
• If he passes the exam, the branch issues
him a driver’s license. A driver’s license
must also record if the driver has
completed driver’s education, for
insurance purposes.
• Create a E-R diagram.
ZICTC@2019 45