Uploaded by zaid ali

Understanding FUNCTIONAL DEPENDENCIES IN NORMALIZATION (1)

advertisement
TYPES OF FUNCTIONAL DEPENDENCIES IN
NORMALIZATION
Functional Dependency:
In Relational database, Functional dependency is denoted as
•
•
•
X -> Y
X: Determ inant
Y: Dependent
so, as per the concept the value of Y gets determined by the value of X. That means, if
value of X gets duplicated, then in those rows value of Y shall also gets duplicated
correspondingly.
If the determinant X value is unique (different) then the dependent Y could have any
value meaning:
•
•
for same X , value of Y should be same.
for different X, value of Y could be sam e or different.
Flow chart used for F.D validation check:
R eflex ive Ax iom :
According to reflexive axiom, always the trivial dependencies like X->X, Y->Y shall be true
and valid for each and every instance of the relation.
Decom position Ax iom :
if there exist functional dependency X->YZ, then as per decomposition axiom, we can
conclude => X->Y and X->Z are valid.
Decomposition axiom should always get applied on dependent side and ot the
determ inant side.
if there exist XY -> Z then X->Z and Y->Z are not valid.
Example:
A
B
C
1
2
3
2
2
3
3
2
3
4
3
2
5
2
3
6
3
2
All pos s ible FD’s of t h e a bove r e la t ion :
1.
2.
3.
4.
A->A : Va lid (Determinant A’s values are unique)
A->B : Va lid (Determinant A’s values are unique)
A->C : Va lid (Determinant A’s values are unique)
B ->A : N ot Va lid (for same determ inant B ’s value ‘2’, dependent A’s value ‘1’,’2′is
different)
5. B ->B : Va lid (Trivial Dependency always valid according to Reflexive Axiom)
6. B ->C : Va lid (for same determinant B value, same dependent C value, for different
B value C value could be anything hence it is valid)
7. C->A : N ot Va lid (for same determ inant C value 3 there are 5 different dependent
A values hence not valid)
8. C->B : Va lid (for same determinant C value that is 3, same dependent B value that
is 2, for different C value B value could be anything hence it is valid)
9. C->C : Va lid (Trivial Dependency always valid according to Reflexive Axiom)
10.
AB ->A : Va lid (A’s values are unique hence determinant AB ’s values will also
be unique, hence dependent A’s value could be anything, AB ->any attribute of
above relation will be valid)
11.
AB ->B : Va lid (A’s values are unique hence determinant AB ’s values will also
be unique, hence dependent B ’s value could be anything, AB ->any attribute of
above relation will be valid)
12.
AB ->C : Va lid (A’s values are unique hence determinant AB ’s values will also
be unique, hence dependent C’s value could be anything, AB ->any attribute or
attributes combination of above relation will be valid)
13.
B C->A : N ot Va lid (for same value {2,3} of determinant B C there are two
values {1},{2}of dependent A, hence not valid)
14.
B C->B : Va lid (for same value {2,3} o determinant B C, same value {2} of
dependent B exist. this holds for any combination of determinant to dependent.
hence it is valid)
15.
B C->C : Va lid (for same value {2,3} o determinant B C, same value {3} of
dependent C exist. this holds for any combination of determinant to dependent.
hence it is valid)
16.
CA->A : Va lid (A’s values are unique hence determinant AC’s or CA’s values
will also be unique, hence dependent A’s value could be anything, CA->any
attribute or attributes com bination of above relation will be valid)
17.
CA->B : Va lid (A’s values are unique hence determinant AC’s or CA’s values
will also be unique, hence dependent B ’s value could be anything, CA->any
attribute or attributes com bination of above relation will be valid)
18.
CA->C : Va lid (A’s values are unique hence determinant AC’s or CA’s values
will also be unique, hence dependent C’s value could be anything, CA->any
attribute or attributes com bination of above relation will be valid)
19.
AB C->A : Va lid (A’s values are unique hence determinant AB C’s values will
also be unique, hence dependent C’s value could be anything, AB C->any attribute
or attributes combination of above relation will be valid)
20.
AB C->B : Va lid (A’s values are unique hence determ inant AB C’s values will
also be unique, hence dependent B ’s value could be anything, AB C->any attribute
or attributes combination of above relation will be valid)
21.
AB C->C : Va lid (A’s values are unique hence determ inant AB C’s values will
also be unique, hence dependent C’s value could be anything, AB C->any attribute
or attributes combination of above relation will be valid)
Different Types of Functional Dependencies used in Normalization process are:
•
•
•
•
Full Dependency
Partial Dependency
Transitive Dependency
Overlapping Candidate Key Dependency
Fu ll Dependency:
A dependency is said to be full if and only if the determ inant of the dependency is either
a candidate key or a super key.
Note: Dependent of the full dependency can be either prim e or non prime attribute.
X -> Y
•
•
X is either candidate key or super key
Y could be any attribute Prime or N on Prime.
Note: Full Dependency will always cause Zero % redundancy hence we need not to
elim inate full dependency.
Pa r t ia l Dependency:
If a N on prime or N on key attribute of the relation is dependent on only a part of
the candidate key then such dependency is defined as partial dependency.
•
•
•
X->Y
X is subset of Candidate Key
Y is Non Prime or N on Key Attribute.
Note:
1. While identifying the partial dependencies make sure that dependent is non
prime/non key and determ inant is part of candidate key.
2. In order to have any partial dependencies, the relation should have at least one of
the candidate key as composite.
3. Partial dependencies will cause redundancies, hence they should get elim inated.
Tr a nsit ive Dependency:
If a non prime attribute of the relation gets derived by either another non prim e attribute
or the com bination of the part of the candidate key along with a non prime attribute is
defined as transitive dependency.
•
•
•
X->Y
X: N on prime or combination of part of candidate key with at least one non prime
attribute
Y: non prime attribute.
Note:
1. While validating the transitive dependency, make sure the dependent is a non
prime attribute and the determinant is either a non prime attribute or the
combination of part of candidate key along with a non prim e attribute.
2. Transitive dependencies will cause redundancy in the relation and hence they
should be eliminated.
3. If a relation has zero non prime attribute then the total no of partial and transitive
dependencies in that relation will be always zero.
Download