Write a program that can input from a set of superkeys and output all possible candidate keys from the input to an output file (named "candidate-keys"). The superkeys of one example look as follows: ABCF CDF ACDF BCDF ABCDF ABCEF CDEF ACDEF BCDEF ABCDEF
The output that contains all possible candidate keys: ABCF CDF
In the example I don't understand how to get the that result from the superkeys, any information would be helpful. Thanks
I think that if the superkeys provided are all the possible superkeys of a relation, an algorithm to find among them the candidate keys is the following:
Consider a pair of superkeys S1, S2. If S1 is contained in S2, eliminate S2. If S2 is contained in S1, eliminate S1. Otherwise keep both.
Repeat the operation for all the couples until no superkey can be eliminated. The remaining ones should be the candidate keys of the relation.