My answer is derived from the Algorithm given in Database System Concepts by Korth.
Are the closures A+,B+,C+,D+,E+,F+ calculated this way?
Steps to calculate the closure of (A,B,C,D,E,F) under F let say take for B
- result = {B}
- repeat
- for each functional dependency(e.g
B -> E
) in F
do
- begin
- if
B
is subset of result
- then
result(i.e B) = result(i.e B) U {E}
- end
- until(result stops changing)
In this way the closures of the following will be:
A+ = A
B+ = ABCDEF
C+ = AC
D+ = D
E+ = E
F+ = F
How to check an attribute is extraneous:
An attribute A is extraneous in a dependency alpha(AB) -> beta(C) if
1) A belongs to beta(which is not in the current case) then create new FD
F' = (F-{alpha -> beta}) U {alpha -> (beta - alpha)}
and check if alpha+ under F'(**not F**) includes A
, then A
is extraneous in beta
.
2) A belongs to alpha(which is correct), then create a new gamma{B} = alpha({AB}) - {A}
and check if gamma+(i.e B+)
under **F** i.e ABCDEF
includes all attributes in beta({C})
and which is true. So A is extraneous in AB->C
.
similarly check if C
is extraneous in AB->C
. So by above suggested algo
F' : AB -> NULL; B →E; CF →D; C →A; B →F; CE →F; CD →B; B →C
- Compute
AB+
under F'
i.e ABCDEF
which includes C
. So C
is extraneous in AB-> C
.
How to compute canonical cover?
Algo:
F' = F
- If there is any FD like
A->B and A->C
then replace by A->BC
(by union rule)
Here the F' become : AB -> C; B-> CEF; C -> A; CD-> B; CE-> F; CF-> D
- Find the extraneous(left/right) in F' i.e
A is extraneous in AB->C
so remove A from AB->C
, so that it becomes B->C
and update F'
.
- Now check if the F' is changed as previous. If changed goto step 2 and repeat until find the F' no longer changes.
(Explaining further iterations as below:
itr2:
F' : B -> C; B-> CEF; C -> A; CD-> B; CE-> F; CF-> D
F' : B-> CEF; C -> A; CD-> B; CE-> F; CF-> D
Now check C in B-> CEF
, which is not extraneous
Check E , which is also not extraneous.
check F ,which is extraneous.
So new F' : B-> CE; C -> A; CD-> B; CE-> F; CF-> D
itr3:
F' : B-> CE; C -> A; CD-> B; CE-> F; CF-> D
after this there is no further extraneous attribute found.
So the canonical cover of F are :
B-> CE
C -> A
CD-> B
CE-> F
CF-> D
Let me know if have some error in logic suggested above.