CS 3430 Lecture Notes - Lecture 24: Foreign Key, Unique Key, Surrogate Key
83
Database Systems – 3430 – Chapter 9.2
Section 9.2 Mapping EER Model to RM
Reviewing Section 9.1
ER-to-Relational Mapping Algorithm
• Step 1: Mapping of Regular Entity Types
• Step 2: Mapping of Weak Entity Types
• Step 3: Mapping of Binary 1:1 Relationship Types
• Step 4: Mapping of Binary 1:N Relationship Types.
• Step 5: Mapping of Binary M:N Relationship Types.
• Step 6: Mapping of Multivalued attributes.
• Step 7: Mapping of N-ary Relationship Types.
EER to RM
• We add two more steps to the 9.1 Algorithm:
Step 8: Mapping of Specialization or Generalization.
Step 9: Mapping of Union Types (Categories).
Step 8: Mapping of Specialization or Generalization.
• There are four options: 8A, 8B, 8C and 8D.
Option 8A: Multiple relations
• Creating separate relations for all subclasses and superclass.
• For the superclass, create a relation like step1 of the algorithm, let’s call it R1.
• For each subclass, create a relation and add the primary key of R1 as foreign
key.
find more resources at oneclass.com
find more resources at oneclass.com
84
Database Systems – 3430 – Chapter 9.2
Example:
Option 8B: Multiple relations
• Creating separate relations for subclasses only.
• For each subclass, create a relation Ri.
• Add all superclass attributes and its primary key to Ri.
• Works only when superclass participation is total.
• Because, otherwise, there would e soe istaes i superlass whih does’t fit
into any of subclasses.
• We would lose their information with 8B mapping.
Example:
find more resources at oneclass.com
find more resources at oneclass.com