Beruflich Dokumente
Kultur Dokumente
Conceptual
model
Logical
model
Physical
model
Mapping of ER Diagram to
Relational Database
Schema
Lesson Outcomes
By the end of the lesson, the students should be able to:
Explain some of the terminologies used in relational
database
Map an ER diagram to relational database schema.
Name
Ali
Chong
Peter
Ali
14355
14111
Elaine
Kumar
ProgCode Program
ICT
Info & Comm. Technology
BIS
Business Information Systems
ICT
Info & Comm. Technology
BIS
Business Information Systems
Electrical & Electronic
EE
Engineering
BIS
Business Information Systems
Year
1
2
2
1
3
3
Normalized relations
StudentID Name
16227 Ali
15113 Chong
15661 Peter
16227 Ali
14355 Elaine
14111 Kumar
ProgCode Year
ICT
1
BIS
2
ICT
2
BIS
1
EE
3
BIS
3
ProgCod
e
Program
ICT
BIS
EE
Relational Database
tuple
Relation name
Attribute names
Primary key
Foreign key an attribute or set of attributes, within one relation that
matches primary key of some (possibly same) relation.
9
Properties of Relations
Relation name is distinct from all other relation names in
relational schema.
Each cell of relation contains exactly one atomic (single) value.
Each attribute has a distinct name.
Values of an attribute are all from the same domain.
Each tuple is distinct; there are no duplicate tuples.
Order of attributes and tuples in a relation has no significance.
10
attr1a
ENT1
rel1
attr1b
11
Contd
Next, select an entity with M on its
side (in M:1 relationship)
Write: Entity_name, (, attributes, the
key of the 1 side, )
attr1a
ENT1
rel1
attr1b
attr2a
ENT2
attr2b
12
Contd
Next, select the M:N relationship
Write: a relation name to represent the
relationship, (, p.k. of entity1, p.k. of
entity2, attributes if any, )
ENT2
rel2
attr23a
attr2a
attr3a
ENT3
attr2b
Underline the two keys, i.e.,
primary/composite key
attr3b
13
Contd - extra
If any of the entity has multivalued
attribute, then:
attr1a
ENT1
rel1
ENT1b(attr1ba, attr1b)
attr1b
ENT1(attr1a)
ENT1b(attr1ba, attr1b, attr1a)
14
Contd - extra
Option 2: if each tuple of the new
relation might be linked to many
tuples of the original relation,
vice-versa (M:N), then
delete the multivalued attribute from
the original relation.
create another new relation. Fill it up
with the keys from both the original
relation and the created relation
earlier.
ENT1(attr1a)
ENT11b(attr1a, attr1ba)
15
Contd - extra
If any of the entity has composite attribute, then:
attr1a
ENT1
rel1
attr1b
attr1b1
attr1b2
create a new relation, create a key attribute and list out all subattributes in the new relation.
ENT1b(attr1ba, attr1b1, attr1b2)
16
Lesson Summary
Relational database schema represents the ERD in the
relational data model
Each entity will create a relation schema, so is the M:N
relationship, multivalued attribute and composite attribute.
17