Functional Dependency
Functional Dependency
Databases
• The set of all those attributes which can be functionally determined from an
attribute set is called as a closure of that attribute set.
• Closure of attribute set {X} is denoted as {X}+.
Steps to Find Closure of an Attribute Set-
Step-01: Add the attributes contained in the attribute set for which closure is being
calculated to the result set.
Step-02: Recursively add the attributes to the result set which can be functionally
determined from the attributes already contained in the result set.
Algorithm:
• Determine X+, the closure of X under functional dependency set F
• X Closure : = will contain X itself;
• Repeat the process as:
• old X Closure : = X Closure;
• for each functional dependency X → Y in FD set do
• Repeat until ( X Closure = old X Closure);
Find closure of QR and PR
• Given relational schema R( P Q R S T U V) having
following attribute P Q R S T U and V, also there is a set of
functional dependency denoted by FD = { P->Q, QR->ST,
PTV->V }.
• Determine Closure of (QR)+ and (PR)+
a) QR+ = QR (as the closure of an attribute or set of
attributes contain same).
Now as per algorithm look into a set of FD that complete
the left side of any FD contains either Q, R, or QR since in
FD QR→ST has complete QR.
Hence QR+ = QRST
• b) PR + = PR (as the closure of an attribute or set of attributes
contain same)
• Now as per algorithm look into a set of FD, and check that complete
left side of any FD contains either P, R, or PR. Since in FD P→Q, P is a
subset of PR, Hence PR+ = PRQ
• Again, trace the remaining two FD that any left part of FD contains
any P, R, Q, Since, in FD QR → ST has its complete left part QR in PQR
• Hence PR+ = PRQST
• Again trace the remaining one FD { PTV->V } that its complete left
belongs to PRQST. Since complete PTV is not in PRQST, hence we
ignore it.
• Therefore PR+ = PRQST ( Answer)
Armstrong’s Axioms in Functional Dependency in DBMS
Example:
X = {a, b, c, d, e}
Y = {a, b, c}
2. Axiom of Augmentation:
Example:
For R(ABCD), if A → B then AC → BC
3. Axiom of Transitivity:
Example:
if (X→Y & Y→Z) then X→Z
Secondary Rules - Union
Proof:
1. X → Y (given)
2. X → Z (given)
3. X → XY (using Augmentation Rule on 1 by augmentation with X.
Where XX = X)
4. XY → YZ (using Augmentation Rule on 2 by augmentation with Y)
5. X → YZ (using Transitive Rule on 3 and 4)
2. Decomposition
If X determines Y and Z, then X determines Y and X determines Z
separately.
i.e, If X → YZ then X → Y and X → Z
Proof:
1. X → YZ (given)
2. YZ → Y (using Reflexivity Rule)
3. X → Y (using Transitive Rule on 1 and 2) ……….(i)
4. X → YZ (given)
5. YZ → Z (using Reflexivity Rule)
6. X → Z (using Transitive Rule on 4 and 5) ………..(ii)
3. Composition
If P holds Q (P → Q) and A holds B (A → B), then PA → QB.
Proof,
1. P → Q (Given)
2. A → B (Given)
3. PA → QA (Augmentation of 1 and A)
4. PA → Q (Decomposition of 3)
5. PA → PB (Augmentation of 2 and P)
6. PA → B (Decomposition of 5)
7. PA → QB (Union 4 and 6)
Find minimal cover/canonical cover in a set of given functional dependencies
• Minimal cover:
• Definition 1:
• A minimal cover of a set of FDs F is a minimal set
of functional dependencies Fmin that is equivalent
to F. There can be many such minimal covers for a
set of functional dependencies F.
• Definition 2:
• A set of FDs F is minimum if F has as few FDs as
any equivalent set of FDs.
Canonical Cover Of Functional Dependency: