Functional Dependencies
Functional Dependencies
Functional Dependencies
NORMALIZATION
FUNCTIONAL DEPENDENCY
Definition: Let α с(subset) R, β с (subset) R. The functional
dependency α →β holds on R if in any legal relation r(R) for all
pairs of tuples t1 and t2 in r such that t1[α]=t2[α], it is also the
case that t1[β]=t2[β].
A B C D
A1 B1 C1 D1
A1 B2 C1 D2
A2 B2 C2 D2
A2 B3 C2 D3
A3 B3 C2 D4
AB→ D holds.
EXAMPLES OF FDS
FDs of Branch_name(branch-name, b_city, assets)
Branch-name→ b_city
Branch-name→ assets
S1 Kolkata P1 100
S2 Mumbai P1 80
S3 Mumbai P2 150
S4 Kolkata P1 110
S5 Kolkata P3 50
The left hand side attributes of the FD s are connected by vertical lines to
the horizontal line representing the FD, while the right –hand-side attributes
are connected by arrow pointing toward the attributes.
TRIVIAL & NON-TRIVIAL DEPENDENCY
Trivial dependency: FD is trivial if and only if the right side is a
subset(not necessarily a proper subset) of the left side. Otherwise FD is
non-trivial.
However other FDs hold in all legal relation instances that satisfy the
dependencies in F. Those dependencies can be deduced or inferred from
the FDs in F. The set of all such dependencies is called the closure of F
and is denoted by F+.
Now, B→ H if t1[B]=t2[B]
then t1[H]=t2[H]
It is shown that whenevert1 and t2 are tuples such that t1[A]=t2[A]
it must be that t1[H]=t2[H]. Hence,
A→H
DETERMINATION OF F+
We can find all of F+ from F by applying Axioms or rules of inference for
functional dependencies repeatedly. These inference rules are called
Armstrong’s axioms.
Self-determination: α→ α
Composition: If α→β, γ →δ holds, then αγ→δβ holds
EXAMPLE
Let us consider a relation schema R=(A,B,C, G, H, I) and the set of FDs
{A→B, A→C, CG→H, CG→I, B→H}, list the several members of F+.
Given, A→BC
By decomposition: A→B, A→C
By augmentation: AD → CD
By sound means: Any dependency that we can infer from a given set of
dependencies F on a relation schema R using Armstrong axioms satisfies
the dependencies in F and every state of relation R.
Solution:
1. result = AG
2. result = ABG (A → B )
3. result = ABCG (A → C )
4. result = ABCGH (CG → H and CG AGBC)
5. result = ABCGHI (CG → I and CG AGBCH)
EXAMPLE
F={ssn→ename,
pnumber→{pname, plocation}
{ssn, pnumber}→hours}
Compute ssn+, pnumber+, {ssn, pnumber}+
Solution:
ssn+={ssn, ename}
pnumber+={pnumber, pname, plocation}
1. Set K := R.
2. For each attribute A in K {
compute (K - A)+ with respect to F;
If (K - A)+ contains all the attributes in R,
then set K := K - {A}; }
CANONICAL COVER
Sets of functional dependencies may have redundant dependencies that
can be inferred from the others
Eg : A → C is redundant in: {A → B, B → C, A → C}
Case 1:
Attribute A is extraneous in a if A a
and F logically implies (F – {a → }) {(a – A) → }.
Example: Given F = {A → C, AB → C }
B is extraneous in AB → C because
Note: implication in the opposite direction is trivial in each of the cases above,
since a “stronger” functional dependency always implies a weaker one
TESTING IF AN ATTRIBUTE IS EXTRANEOUS
Consider a set F of functional dependencies and the functional dependency a
→ in F.
Case 1:
To test if attribute A a is extraneous in a
1. compute ({a} – A)+ using the dependencies in F
2. check that ({a} – A)+ contains all attributes in ; if it does, A is
extraneous
Example: Given F = {A → C, AB → C }
B is extraneous in AB → C
Example:
F={AB→CD, A→E, E→C}. Check whether C is extraneous in
AB→CD.
Solution: Compute AB+ under FC= {AB→D, A→E, E→C}.
AB+=ABDEC, it includes C. So C is extraneous.
CANONICAL COVER
A canonical cover for F is a set of dependencies Fc such that
F logically implies all dependencies in Fc, and
C is extraneous in A → BC
Check if A → C is logically implied by A → B and the other
dependencies
Using transitivity on A → B and B → C.