Functional Dependency
B. Krishnakumar
Functional Dependencies - Example
title year →length
title year →filmType
title year →studioName
shorthand: title year →length filmType studioName
Superkeys
then the keys of both connected entity sets are the key attributes for R.
then the key attributes of E1 are the key attributes of R, but those of E2 are not.
then the key attributes for either of the connected ES’s are key attributes of R.
Discovering Keys for Relations – �E/R to Relations
Example
Movies
Stars-In
Stars
length
filmType
title
year
Owns
Studios
name
address
name
address
title+year, which come from the key for Movies.
(title+year)+starName, which come from the key for Movies and the key for Stars.
(Continued)
(Continued)
Rules About Functional Dependencies
The Splitting/Combining Rule
A1A2…An→B1
A1A2…An→B2
…
A1A2…An→Bm
A1A2…An→B1B2…Bm.
Combining Rule
Splitting Rule
Trivial Dependencies
Computing the Closure of Attributes
B1B2…Bm→C
such that all of B’s are in the set X, but C is not. We then add C to X.
Since X can only grow, and the number of attributes is finite, eventually nothing more can be added to X.
Computing the Closure of Attributes - Algorithm
AB→C,
BC→AD,
D→E,
CF→B.
What is {A,B}+?
Computing the Closure of Attributes - Example
Computing the Closure of Attributes (Continued)
AB→D
follows from the set of the dependencies.
Yes! Since D∈{A,B,C,D,E} = {A,B}+.
On the other hand consider testing the FD: D→A.
Computing the Closure of Attributes (Continued)
Closures and Keys