Unit 4 Attribute-Closure
Unit 4 Attribute-Closure
A Closure is a set of FDs is a set of all possible FDs that can be derived from a given set of
FDs. It is also referred as a Complete set of FDs. If F is used to donate the set of FDs for
relation R, then a closure of a set of FDs implied by F is denoted by F+. Let's consider the set
F of functional dependencies given below:
F = {A -> B, B -> C, C -> D}
from F, it is possible to derive following dependencies.
1.A -> A ...By using Rule-4, Self-Determination. reflexive
//2.A -> B ...Already given in F. Given in question
3.A -> C ...By using rule-3, Transitivity.
4.A -> D ...By using rule-3, Transitivity.
Now, by applyiing Rule-6 Union, it is possible to derive A+ -> ABCD and it can be denoted
using 5.A -> ABCD. All such type of FDs derived from each FD of F form a closure of F.
Attribute CLOSUURE
Steps:
1. X+ = X //initialize X+ to X
2. For each FD : Y -> Z in F Do
If Y ⊆ X+ Then //If Y is contained in X+
+ +
X = X ∪ Z //add Z to X+
End If
End For
3. Return X+ //Return closure of X
Example-
F={A → BC
BC → DE
D→F
CF → G}
Now, let us find the closure of some attributes and attribute sets-
Q1.find ABC+?
ABC+=ABC STEP1
=ABC U BC
=ABC
={ABC} u {DE}
=ABCDE
={ABCDE} U{ F}
=ABCDEF
={ABCDEF}U {G}
=ABCDEFG
FINALLY ABC+?=ABCDEFG
A+ = { A }
= { A , B , C } ( Using A → BC )
= { A , B , C , D , E } ( Using BC → DE )
= { A , B , C , D , E , F } ( Using D → F )
= { A , B , C , D , E , F , G } ( Using CF → G )
Thus,
A+ = { A , B , C , D , E , F , G }
D+ = { D }
= { D , F } ( Using D → F )
We can not determine any other attribute using attributes D and F contained in the result set.
Thus,
D+ = { D , F }
{ B , C }+= { B , C }
= { B , C , D , E } ( Using BC → DE )
= { B , C , D , E , F } ( Using D → F )
= { B , C , D , E , F , G } ( Using CF → G )
Thus,
{ B , C }+ = { B , C , D , E , F , G }
Problem-
AB → CD
AF → D
DE → F
C→G
F→E
G→A
(A) { CF }+ = { A , C , D , E , F , G }
(B) { BG }+ = { A , B , C , D , G }
(C) { AF }+ = { A , C , D , E , F , G }
(D) { AB }+ = { A , C , D , F ,G }
Solution-
Option-(A):
{ CF }+ = { C , F }
= { C , F , G } ( Using C → G )
= { C , E , F , G } ( Using F → E )
= { A , C , E , E , F } ( Using G → A )
= { A , C , D , E , F , G } ( Using AF → D )
Since, our obtained result set is same as the given result set, so, it means it is correctly given.
Option-(B):
{ BG }+ = { B , G }
= { A , B , G } ( Using G → A )
= { A , B , C , D , G } ( Using AB → CD )
Since, our obtained result set is same as the given result set, so, it means it is correctly given.
Option-(C):
{ AF }+ = { A , F }
= { A , D , F } ( Using AF → D )
= { A , D , E , F } ( Using F → E )
Since, our obtained result set is different from the given result set, so,it means it is not
correctly given.
Option-(D):
{ AB }+ = { A , B }
= { A , B , C , D } ( Using AB → CD )
= { A , B , C , D , G } ( Using C → G )
Since, our obtained result set is different from the given result set, so,it means it is not
correctly given.
Thus,