Rules of Functional Dependencies PDF
Rules of Functional Dependencies PDF
result ← A;
while (result changes) do
for each functional dependency B → C in F
if B is contained in result then result ←
result C;
end;
A+ ← result;
Uses of Attribute closure
Testing for super key: To check if the
attribute(s) closure A+ contains all
attributes of R
Testing functional dependencies: To
check if a functional dependency X→Y
holds (or, in other words, is in F+), just
check if Y⊆X+
Exercise:
If R(ABCDEF) is given and a set F =
{ABC, ADE, BD, AFB} holds.
a) Determine the closure of all the
determinants
b) Find any 3 super keys of R
c) Find a candidate key of R
Exercise
Given relation R(A,B,C,D,E,F) and a set
of FDs F that hold on R:
F= {A → B, A → C, CD → E, CD → F, B
→E}
a. Show that ADF is a super key
b. Determine if ADF is a candidate key
Exercise
Consider a relation R(A,B,C,D,E)
with set of Functional Dependencies
(FDs) F ={AB, BCE, EDA}
Determine
Two Candidate keys of R
Redundant FDs
Redundant FDs
A functional dependency in the set
is redundant if it can be derived
from the other functional
dependencies in the set.
Apply Armstrong’s axioms to remove
redundant FDs
Steps for determining redundant
FDs.
Step 1: Start with a set of S of functional dependencies
(FDs).
Step 2: Remove an FD f and create a set of FDs S' = S -
f.
Step 3: Test whether f can be derived from the FDs
in S'; by using the set of Armstrong's axioms and
derived rules.
Step 4: If f can be so derived, it is redundant , and
hence S' = S. Otherwise replace f into S'; so that
now S' = S + f.
Step 5: Repeat steps 2 to 4 for all FDs in S.
Example
Given that the set of FDs F= {AB, B
C, A C }
hold on R(ABC). Show that A C is a
redundant.
F- {AC} = {AB, B C} =S
AC transitively dependent on A
Example
Given that the set of FDs F holds on R(A, B, X, Y, Z).
Show that ZB Y is a redundant FD in F
F= {ZA, B X, AX Y, ZB Y}
F- ZB Y = {ZA, B X, AX Y} =S
Z A by augmentation rule will yield ZB AB.
B X and AX Y by the pseudo-transitivity rule
will yield AB Y.
ZB AB and AB Y by transitivity rule will yield
ZBY.
F+ = S+
Membership Algorithm for
determining redundant FDs.
Input: Set F of FDs that hold for R
1. Choose an FD f(X Y) and remove it from F such that F’ =
F-f
2. result ← X;
3. for each FD, A → B, remaining in the reduced set of FDs F’
Do
If A ⊆ result
then result = result B
endif
4. if Y ⊆ result
then the FD X → Y is redundant.
endif
Exercise
1. Given that the set of FDs F = {AB, B C, A C } holds on R(ABC).
Use the Membership algorithm to remove redundant FDs in F
2. Given that the set of FDs F = {ZA, BX, AXY, ZBY}
holds on R(ABXYZ). Use the Membership algorithm to
remove redundant FDs in F
3. A relational schema R(ABCDE) is given and a set of functional
dependencies F = {A B, C D, BD E, AC E} holds on R.
Use the Membership algorithm to show that AC E is redundant
FDs in F
4. Given relation R(A, B, C, D, E, F) and a set of FDs F that holds on R.
F = {AB, A C, A F, EC, EF, BF, CD E, CDF}
a) Find the closure of CD
b) Find any two super keys of R
c) Determine candidate key for R.
Canonical Cover
Canonical Cover of F
A canonical cover of F is a “minimal” set of functional
dependencies equivalent to F, having no redundant
dependencies or redundant parts of dependencies
There may be further redundancy in a set of FDs in the
form of redundant attributes in the determinants of
the FDs.
If we also remove such attributes we arrive at what is
called a minimal cover for the set of FDs.
The minimal cover must also have the property of
having single attributes on the right hand side of all
FDs in the set.
Canonical cover ctd
The minimal cover for a set of FDs F is the set of FDs
G such that:
G+ = F+ (that is G and F are equivalent)
the right hand side of each FD in G is a single
attribute
G is minimal, that is, if we remove any attribute
from an FD in G or remove any FD from G, then G+
will no longer equal F
Minimal Set of Functional
Dependencies
A set of FDs, F, is said to be minimal if it satisfies these
three conditions
1. the right side of every FD in F has a single attribute.
This form is called standard or canonical form for
FDs.
2. no attribute on the left side of any FD in F is
extraneous. This means that if X → Y is an FD in F
then there is no proper subset S of X such that S → Y
can be used in place of X → Y and the resulting set is
equivalent to F.
3. F has no redundant FDs.
Examples
Given F = {A → B, AB → C }
F is canonical RHD single attributes
B is extraneous in AB → C because
{A → B, AB → C} logically implies A → C
(i.e. the result of dropping B from
AB → C)
F becomes {AB, AC}
Examples
Given F = {A → C, AB → CD}
F is not canonical,
By decomposition rule AB CD AB C,
AB D
F becomes {A → C, AB C, AB D}
ABC is redundant
F becomes {A → C, AB D}
Exercise
Consider following set F of functional dependencies on
schema R(A, B, C) and compute the minimal cover for F = {A
BC, B C, A B, AB C}
Canonical form
F={AB, AC, BC, AB, ABC}
Remove extraneous FDs from LHS
F={AB, AC, BC, AB, ABC}
ABC; B is extraneous because AB
F becomes F={AB, AC, BC, AB}
Remove redundant FDs
F={AB, AC, BC, AB}
Minimal cover
F={AB, BC}
Exercise
Consider relation R(ABCDE) with the following set of FDs
F={AC → B, CE → D, C → E, D → B } and compute the
minimal cover of F.
Express F in canonical form
F={AC → B, CE → D, C → E, D → B }
Remove extraneous attributes LHS
F={AC → B, CE → D, C → E, D → B }
F={AC → B, C → D, C → E, D → B }
Remove redundant FDs
F={AC → B; C → D; C → E; D → B }
Minimal cover F={C → D, C → E, D → B }
Exercise
Given R(A, B, C) and F = {A → BC, B → C, A → B, AB →
C} that hold on R. Find the minimal cover of F
1. F= {A → B, AC, B → C, A → B, AB → C} {A →
B, AC, B → C, AB → C}
2. A is extraneous in AB → C, B → C is already present
Now, F = {A → B, AC, B → C}
3. AC is redundant, A → C is logically implied by A
→ B and B C transitively. Or use attribute closure
The minimal set is: {A → B, B → C}