0% found this document useful (0 votes)
82 views2 pages

FDs Solutions

This document contains an example of functional dependencies (FDs) for a relation R with attributes ABCD. It provides solutions to exercises about FDs, including: 1) An instance that violates the FD BC → D 2) Why the sets of FDs A → BC and A → B, A → C are equivalent 3) Why the sets PQ → R and P → Q, P → R are not equivalent 4) Checking if an FD follows from a given set of FDs 5) Projecting a set of FDs onto a subset of attributes

Uploaded by

Varun Makkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views2 pages

FDs Solutions

This document contains an example of functional dependencies (FDs) for a relation R with attributes ABCD. It provides solutions to exercises about FDs, including: 1) An instance that violates the FD BC → D 2) Why the sets of FDs A → BC and A → B, A → C are equivalent 3) Why the sets PQ → R and P → Q, P → R are not equivalent 4) Checking if an FD follows from a given set of FDs 5) Projecting a set of FDs onto a subset of attributes

Uploaded by

Varun Makkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

University of Toronto

CSC343 Fall 2014

In-class Exercises: Functional Dependencies


Suppose we have a relation R with attributes ABCD
1. What an FD means. Suppose the functional dependency BC → D holds in R. Create an instance of R that violates
this FD.
Solution:

In order to violate this FD, we need two tuples with the same value for B and the same value for C (both!), yet different
values for D.

A B C D
1 3 6 4
2 3 6 5

2. Equivalent sets of FDs.


(a) Are the sets A → BC and A → B, A → C equivalent? If yes, explain why. If no, construct an instance of R that
satisfies one set of FDs but not the other.
Solution:

These are equivalent — there is no instance of the relation that satisfies one but not the other. This can be proven,
as follows:
• Assume that A → BC.
– Under this assumption, A+ = ABC.
– Therefore A → B, and A → C.
• Assume that A → B, and A → C.
– Under this assumption, A+ = ABC.
– Therefore A → BC.
• Therefore each set of FDs follows from the other. They are equivalent.
(b) Are the sets P Q → R and P → Q, P → R equivalent? If yes, explain why. If no, construct an instance of R that
satisfies one set of FDs but not the other.
Solution:

These are not equivalent, as demonstrated by this instance that satisfies P Q → R but not P → Q, P → R:

P Q R
1 2 4
3 2 5
In fact we can always “split the RHS” of an FD.
3. Keys and FDs.

(a) We claimed that if a set of attributes K functionally determines all attributes, K must be a superkey (i.e., no two
tuples can agree on all attributes in K). Do you believe this? Suppose these FDs hold in R: A → BC, C → D.
Does A functionally determine all attributes of R? Can two tuples agree on A?
Solution:

This is left as an exercise to explore on your own, in order to build your intuition.
(b) We also said that if K is a superkey (i.e., no two tuples can agree on all attributes in K) K must functionally
determine all attributes. Do you believe this? Suppose A is a superkey of R Does A functionally determine all
attributes of R?
Solution:

Again, this is left as an intuition-building exercise.

4. Does an FD follow from a set of FDs? Suppose we have a relation on attributes ABCDEF with these FDs:

AC → F, CEF → B, C → D, DC → A

(a) Does it follow that C → F ?


(b) Does it follow that ACD → B?
Solution:

We use the closure test to check whether an FD follow from a set of FDs.
C + = CDAF . Therefore, C → F does follow.
ACD+ = ACDF . Therefore, ACD → B does not follow.

5. Projecting a set of FDs onto a subset of the attributes. Suppose we have a relation on attributes ABCDE
with these FDs:
A → C, C → E, E → BD

(a) Project the FDs onto attributes ABC.


Solution:

To project onto a set of attributes, we systematically consider every possible LHS of an FD that might hold on
those attributes.
• A+ = ACEBD, therefore A → BC. (It also functionally determines DE, but these are not in our set of
attributes. And it functionally determines itself, but we don’t need to write down dependencies that are
tautologies.)
• B + = B. This yields no FDs for our set of attributes.
• C + = CEBD, therfore C → B.
• We don’t need to consider any supersets of A. A already determines all of our attributes ABC, so supersets
of A will be only yield FDs that already follow from A → BC.
• The only remaining subset of the attributes ABC to consider is BC. BC + = BCED. This yields no FDs for
our set of attributes.
• So the projection of the FDs onto ABC is: {A → BC, C → B}.
(b) Project the FDs onto attributes ADE.
Solution:
• A+ = ACEBD, therefore A → DE.
• D+ = D. This yields no non-trivial FDs..
• E + = EBD, therfore E → D.
• Again, we don’t need to consider any supersets of A, since A determines all the attributes ADE also.
• The only remaining subset of the attributes ABC to consider is DE. DE + = DEB. This yields no FDs for
our set of attributes.
• So the projection of the FDs onto ADE is: {A → DE, E → D}.

You might also like