Closure of Attribute Set - Alternate Way / Closure of Attribute Set Algorithm / How do we find a key given a set of attributes? / How to find super key? / Attribute Closure in DBMS / Closure of Attributes Set Example
To find the Closure of attribute/attribute set A, we have to do the following;
a)
First of all find the set of all functional dependencies (F+) that
are implied by a given set of functional dependencies (F).
b)
Then take all the FDs from F+ that has A on the left hand side of
the arrow.
C)
Finally, find the union of right hand side of all those functional dependencies
that have A on the left hand side. If the union includes all the attributes of
the given relation R, then A is the key for the relation.
Example:
Assume a relation schema R = (A,
B, C) with the set of functional dependencies F = {A → B,
B →
C}.
Now, we can find the closure of attribute A as follows, according to this
method;
Step
1:
Find the F+.
F+ = { A → B, B → C, A → C } [A → C is derived using Transitivity rule]
Step 2: A → B, and A → C are the two functional dependencies that have
common left hand side attribute A.
Step 3: The union of right hand sides ends with A → BC. Hence, A is the one of the keys for the relation R.
Advantages:
- Simple.
Drawbacks:
- The number of functional dependencies in F+ can be as many as 2n+1 where n is the number of attributes. It costs too much of time.