Translation of ER-diagram Into Relational Schema
Translation of ER-diagram Into Relational Schema
Translation of ER-diagram Into Relational Schema
Schema
1
Outline
1.What is a Well-structured Relation?
2. Steps to Transform E-R Diagrams into Relations
3. Converting Regular Entities into Relations
4. Converting Weak Entity types into Relations
5.Converting Unary Relationships into Relations
6.Converting Binary Relationships into Relations
7. Mapping Ternary (and n-ary) Relationships
8.Mapping Supertype/subtype relationships
2
3
1.What is a Well-structured Relation?
4
2. Steps to Transform E-R Diagrams into Relations
5
6
3. Converting Regular Entities into Relations(1)
7
3. Converting Regular Entities into Relations (2)
– Weak entity becomes a separate relation with a foreign key taken from
the strong entity type.
– The primary key is composed of:
• Partial identifier of weak entity
• Primary key of strong entity
4. Converting Weak Entity types into Relations(2)
5.Converting Unary Relationships into Relations(1)
11
5.Converting Unary Relationships to Relations(2)
14
6.Converting Binary Relationships into Relations(2)
PASSENGER TICKET
NAME DEPARTURE
ADDRESS
Foreign Key PID
15
6.Converting Binary Relationships into Relations(3)
• The primary key on the “one” side migrates to the “many” side . The foreign key is
always added into the “Many” side
16
6.Converting Binary Relationships into Relations(4)
Example 1
Instructor
InstructorID Primary Key CourseSection
FirstName CNAME
Office CID
Department
Semester
Foreign Key TeacherID
17
6.Converting Binary Relationships into Relations(5)
Example 2
Department Employee
DeptName DeptID
Foreign Key
Location EmpName
18
6.Converting Binary Relationships into Relations(6)
19
M:N Relationship Example 1
M:N Relationship Example 2
Transforming N:M Example 2
– One relation for each entity and one for the associative entity.
– Associative entity has foreign keys to each entity in the relationship.
7. Mapping a Ternary relationship into relations
8.Mapping Supertype/subtype relationships(1)
7.Mapping Supertype/subtype relationships(2)
End of Chapter 3
27