0

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 above, how do you get the possible candidate keys output from that set of superkeys? I don't understand how to get that result, please help.

1 Answers1

0

A very simple algorithm to find all the candidate keys from the set of all the possible keys and superkeys is the following (in pseudocode):

Input: A set SK of all the (candidate keys and) superkeys of a relation R
Output: The set K of all the candidate keys of SK

Let K = SK
For each k in K do:
    Remove all the keys sk in K such that k is a proper subset of sk

At the end of the loop, the set K will contain the result expected.

Renzo
  • 26,848
  • 5
  • 49
  • 61