Manipulating Functional Dependencies
Zaki Malik
September 30, 2008
September 30, 2008
Definition of Functional Dependency
• If t is a tuple in a relation R and A is an attribute of R, then tA
is the value of attribute A in tuple t.
• The FD AdvisorId Æ AdvisorName holds in R if in every instance of R, for every pair of tuples t
,
yp
p
and u
2
Rules for Manipulating FDs
Rules for Manipulating FDs
Learn how to reason about FDs.
Define rules for deriving new FDs from a given set of FDs.
U th
Use these rules to remove “anomalies” from relational designs.
l t
“
li ” f
l ti
ld i
Example: A relation R with attributes A, B, and C, satisfies the FDs
A Æ B and B Æ
A Æ
B and B Æ C. What other FDs does it satisfy? C What other FDs does it satisfy?
A Æ C
• What is the key for R ?
y
•
•
•
•
– A, because A Æ B and A Æ C
3
Splitting and Combining FDs
Splitting and Combining FDs
• Can we split and combine left hand sides of FDs?
– No !
4
Triviality of FDs
5
Closure of FD sets
• Given a relation schema R and set S of FDs
– is the FD F
is the FD F logically implied by S? logically implied by S?
• Example
– R R = {A,B,C,G,H,I}
{A B C G H I}
– S = A ÆB, A Æ C, CG Æ H, CG Æ I, B Æ H
– would A Æ H be logically implied? – yes (you can prove this, using the definition of FD)
+
• Closure of S: = all FDs logically implied by S
S
+
• How to compute ? S
– we can use Armstrong's axioms
6
Armstrong'ss Axioms
Armstrong
Axioms
• Reflexivityy rule
– A1 A2 ... An Æ a subset of A1 A2 ... An
• Augmentation rule
– A1 A2 ... An Æ B1 B2 ... Bm
then A1 A2 2 ... A
An C1 C2 2 ... C
Ck k Æ B1 B2 2 ... B
Bm C1 C2 2 ... C
Ck k
• Transitivity rule
– A1 A2 2 ... A
An Æ B1 B2 2 ... B
Bm and and
B1 B2 ... Bm Æ C1 C2 ... Ck
then
A1 A2 ... An Æ C1 C2 ... Ck
7
+
Inferring using Armstrong's Axioms
S
+
• S = S
• Loop
– For each F in S, apply reflexivity and augmentation rules
– add the new FDs to S +
– For each pair of FDs in S, apply the transitivity rule
+
– add the new FD to S
+
• Until does not change any further
S
8
Additional Rules
• Union rule
– X Æ Y and X
Y and X Æ Z, then X
Z then X Æ YZ
– (X, Y, Z are sets of attributes)
• Decomposition rule
– X Æ YZ, then X Æ Y and X Æ Z
• Pseudo‐transitivity rule
– X Æ Y and YZ Æ U, then XZ Æ U
• These rules can be inferred from Armstrong's axioms These rules can be inferred from Armstrong's axioms
9
Example
• R = (A, B, C, G, H, I)
F = { A → B A → C CG → H
• some members of F+
A → H CG → I B → H}
• by transitivity from A → B and B → H
AG →
AG I I
• by augmenting A → C with G, to get AG → CG and then transitivity with CG → I CG →
CG HI HI
• from CG → H and CG → I : “union rule” can be inferred from
– definition of functional dependencies, or – Augmentation of CG → I to infer CG → CGI, augmentation of
CG → H to infer CGI → HI, and then transitivity
Closures of Attributes
11
Closures of Attributes: Definition
12
Closures of Attributes: Algorithm
13
Closures of Attributes: Algorithm
Closures of Attributes: Algorithm
• Basis: Y + = Y
• Induction: Look for an FD’s left side X that is a subset of the current Y +
– If the FD is X ‐> A, add A to Y +
Diagramatically:
g
y
X
Y+
A
new Y+
Why is the Concept of Closures Useful?
y
p
Uses of Attribute Closure
There are several uses of the attribute closure algorithm:
• Testing for superkey:
Testing for superkey:
– To test if α is a superkey, we compute α+, and check if α+ contains all attributes of R.
• Testing functional dependencies
– To check if a functional dependency α → β holds (or, in other words is in F+), just check if β
other words, is in F
) just check if β ⊆ α+. – That is, we compute α+ by using attribute closure, and then check if it contains β. β
– Is a simple and cheap test, and very useful
• Computing closure of F
– For each γ ⊆ R, we find the closure γ+, and for each S ⊆ γ+, we output a functional dependency γ → S.
Example of Attribute Set Closure
• R = (A, B, C, G, H, I)
• F = {A →
{
B A → C CG → H CG → I B → H}}
• (AG)+
1. result = AG
2 (A →
2.
(A C and A →
C d A B) result = ABCG
l ABCG
3. (CG → H and CG ⊆ AGBC) result = ABCGH
4. (CG →
(CG → I and CG ⊆
and CG ⊆ AGBCH) result result = ABCGHI
•
•
Is AG a super key? Is AG a key?
1. Does A+ → R?
2 Does G
2.
Does G+ → R?
Example of Closure Computation
© Copyright 2026 Paperzz