1. To test whether a set of attributes is a superkey, we need to nd the set of attributes functionally determined by α.
2. Let be a set of attributes. We call the set of attributes determined by under a set F of functional dependencies the closure of under F,denoted α+.
3. The following algorithm computes α+:
result:= α
while (changes to result) do
for each functional dependency β→ γ
in F do
begin
if β ∈result
then result := result ∪γ;
end
4. If we use this algorithm on our example to calculate (AG+) then we nd:
- We start with result = AG.
- A → B causes us to include B in result.
- A → C causes result to become ABCG.
- CG → H causes result to become ABCGH.
- CG → I causes result to become ABCGHI.
- The next time we execute the while loop, no new attributes are added, and the algorithm terminates.
5. This algorithm has worst case behavior quadratic in the size of F. There is a linear algorithm that is more complicated.
