(JF) Tutorial 2 ER Modelling Solutions 24oct2020
(JF) Tutorial 2 ER Modelling Solutions 24oct2020
a)
Company operates Department
1..1 *..*
employs
b) Department Employee
1..1 1..*
c) has
Employee hhas Dependent
1..1 0..*
employs
1..*
Dependent has Employee
0..* 1..1
Question Three
a) Entities and their attributes
Customer {custNo, name (firstName, lastName), address(street, city, postcode), phone, credit}
CustNo: unique
name, address: composite
compProduct
0..*
HasComponent Product
Order
mainProduct prodNo{PK}
description Requests orderNo{PK}
0..1 price
1..* 0..* dateDue
cost totalPrice
stock quantity status
reorderLevel
recorderQty 0..*
Places
1..1
Customer
custNo{PK}
name
firstName
lastName
address
city
street
postCode
phone
credit
Option B:
If we have many entities and many relationships it is difficult to draw an ER diagram on a single page. In such cases:
Draw partial ER diagrams of entities and their attributes;
Draw a simplified ‘global’ ER diagram showing:
Entities and a single attribute (primary key);
Relationships, structural constraints, and attributes (if any);
d) Partial ER diagrams
Customer
Product Order
custNo{PK}
prodNo{PK} orderNo{PK} name
description dateDue firstName
price totalPrice lastName
cost status address
stock
city
reorderLevel
street
recorderQty
postCode
phone
credit
e) Simplifed ER diagram
compProduct
0..*
Product Order
HasComponent Requests
prodNo orderNo
mainProduct
1..* 0..*
0..1
quantity 0..*
Places
1..1
Customer
custNo
Question Four
a) Entities and their attributes
Publisher {name, address (town, street, postcode), phoneNo, faxNo, webAddress, eamilAddress}
name, phoneNo, faxNo, webAddress, emailAddress – unique
address – composite
PrintItem Book
itemCode{PK} ISBN{PK}
name{AK} Title
description yearOfPublication
price
authors[1..*]
d) Simplified ER diagram
1..4
PartOf
0..2
TeachingTeam Course OferedIn TrainingSession
Teaches
teamNo 1..1 1..* code 1..* *..* sessionNo
*..*
Joinstake. But we still cannot
Creating a relationship between the TRAINEE and COURSE we can answer the question: which courses did a trainee
answer the second question: which courses did he/she take and in which session? 1..100
To answer the second question, we need to remove the Fan trap by creating a ternary relationship betweenTrainee
Trainee, TrainingSession and course.
This will replace the two many-to-many ( *:*) relationships (OfferedIn, and Joins). matricNo
For further thinking: will the loss of the two binary relationships result in information loss, for example, we can no long capture what training
session a trainee joins?
c) Fan trap removed
TrainingSession Trainee
sessionNo T-C-T
matricNo