Exercise08 Solution
Exercise08 Solution
The exercises marked with * will be discussed in the exercise session. You can solve the other
exercises as practice, ask questions about them in the session, and hand them in for feedback.
All exercises may be relevant for the exam.
Ask Ingo (ingo.mueller@inf.ethz.ch) for feedback on this week’s exercise sheet or give it
to the TA of your session (preferably stapled and with your e-mail address).
Assumptions:
• The sales tax (VAT) value can vary from product to product (e.g. 8% for books, 16% for
luxury items).
• The gross total is the net total price plus the sales tax.
• Customer orders on the same day are combined. We only have one order per customer and
per day.
• Properties do not change over time – everything is “write-once”.
Data Modelling and Databases (DMDB), Spring Semester 2017, Exercise 8: Functional
Dependencies, April 28, 2017 Legi-Nr:
Questions:
1. Determine all functional dependencies of the relation Order.
Solution:
Note: If the product/customer names are unique, one could also consider the following
functional dependencies:
Note: Because of the correlation between Net_Total, VAT and Gross_Total, one could
also consider the following functional dependencies:
Note: Because of the correlation between Net_Total, Amount and Item_Price, one
could also consider the following functional dependencies:
Note: More functional dependencies are in the closure of the ones given above, but have
been omitted for sake of brevity.
Solution:
Note: If product/customer names are unique, we have the following additional key
candidates:
Data Modelling and Databases (DMDB), Spring Semester 2017, Exercise 8: Functional
Dependencies, April 28, 2017 Legi-Nr:
Note:
• Assume that there is exactly one teaching assistant assigned to each student for every
course.
Questions:
1. Determine all functional dependencies of the relation above.
Solution:
• Student_Id → Address
• Student_Id, Course → T eaching_Assistant
Solution:
Questions:
Solution:
Solution: {A, D}
AB → C D → EG C→A BE → C
BC → D CG → BD ACD → B CE → AG
For the following statements, decide whether they are true or false. For false statements, explain
why you think that they are wrong.
Data Modelling and Databases (DMDB), Spring Semester 2017, Exercise 8: Functional
Dependencies, April 28, 2017 Legi-Nr:
Explanation:
1. The closure of BC includes the elements themselves. It is {A, B, C, D, E, G}.
2. From the previous question we know that the closure of BC is {A, B, C, D, E, G}.
3. C → A is the only functional dependency that can be used.
4. Since the closure of BC includes all elements, ABC is a super key.
5. ABC is not minimal, hence it is not a candidate key. BC is a candidate key.
2 Minimal Basis*
Find a minimal basis of the following sets of functional dependencies.
Solution:
Solution:
AB → C, C → A, BC → D, BE → C,
CE → F , CF → B, D → EF
3 Decomposition*
3.1 Student – Lecture Relation
Consider the following relation S and its decomposition into S1 and S2 .
Note:
• Assume that each course is always taught only by the same professor and takes place in
the same room.
Questions:
1. Determine all functional dependencies of S.
Solution:
3. Show a lossless decomposition of the same relation, and prove that it is lossless.
Data Modelling and Databases (DMDB), Spring Semester 2017, Exercise 8: Functional
Dependencies, April 28, 2017 Legi-Nr:
Hints:
• Assume the elements of R1 and R2 have the forms (α, β) and (α, γ) with α = {A1 , ..., Ai },
β = {B1 , ..., Bj }, and γ = {C1 , ..., Ck }, respectively.
• First prove R ⊆ R1 ./ R2
• Next, prove R1 ./ R2 ⊆ R
Direction 1: R ⊆ R1 ./ R2
Q Q
If (a, b, c) ∈ R ⇒ (a, b) ∈ R1 (R) = R1 and (a, c) ∈ R2 (R) = R2
⇒ (a, b, c) ∈ R1 ./ R2
Direction 2: R1 ./ R2 ⊆ R
If (a, b, c) ∈ R1 ./ R2 ⇒ (a, b) ∈ R1 and (a, c) ∈ Q
R2
⇒ (a, b, c0 ) ∈ R such that R1 Q
((a, b, c0 )) = (a, b),
and (a, b , c) ∈ R such that R2 ((a, b0 , c)) = (a, c)
0
α→β ⇒ b = b0
⇒ (a, b0 , c) = (a, b, c) ∈ R
father mother
man woman
1 1
isSon isDaughter
Solution:
2. Which additional functional dependencies would you add to represent the real world more
accurately?
Solution:
3. Determine the minimal basis of all functional dependencies (including the ones you added).
Solution: With the right-reduction rule, the right side of each functional dependency
of Part 1 can be made empty because it is already implied by a functional dependency of
Part 2. The reduced functional dependency can then be removed and only the following
remain: