UNIT 03-P2 Logical Data Modeling Using The Relational Model
UNIT 03-P2 Logical Data Modeling Using The Relational Model
Foreign Key
Primary Key
Possible
Approaches
TS PK a1 a2 ………. an
Primary Key
Dr. Suleiman H. Mustafa Slide 3-2 - 16
Mapping of One-To-One (1:1) Relationships
S PK FK a1 ……… an
Dr. Suleiman H. Mustafa Slide 3-2 - 18
Mapping of Binary 1:1 Relation Type
Add FK
Step 4: Continues
Include as foreign key in S the primary key of the
relation T.
Include any simple attributes of the 1:N relationship as
attributes of S.
relation S relation T
Add FK
supervisor supervisee
n
1
SUPERVISION
relation S relation T
supervisee
EMPLOYEE SUPERVISION EMPLOYEE
n 1
The many side supervisor
Dr. Suleiman H. Mustafa Slide 3-2 - 26
Mapping of Binary 1:N Relationship Types.
Add FK
relation T relation S
DEPARTMENT CONTROLS PROJECT
1 n
The many side
Add FK
T R S
n m
Given the two relations T and S
T(PK, a1, a2, …, an)
S(PK, a1, a2, …, an)
T R S
n m
Hours
Add FK
K
R FK a
A
E
K
R FK a
Attribute A
Primary Key
Dr. Suleiman H. Mustafa Slide 3-2 - 38
The Final Relational Database Schema for the COMPANY Database
Example
The relationship SUPPLY in the ER on the next slide.
This can be mapped to the relation SUPPLY shown in
the relational schema, whose primary key is the
combination of the three foreign keys {SNAME,
PARTNO, PROJNAME}
a1 ….
…. an
K a2
S1 S2 …. Sm
…. …. ….
…. …. ….
a1 a1 a1
…. …. ….
…. …. ….
a1 a1 a1
Discriminating Attribute
Discriminating Attribute
subclass Attributes
S1 S2 …. Sm
…. …. ….
…. …. ….
a1 a1 a1
K K K