【问题标题】:How to find all possible candidate keys from a set of superkeys?如何从一组超级键中找到所有可能的候选键?
【发布时间】:2015-10-04 22:01:51
【问题描述】:

一个示例的超级键如下所示: ABCF CDF ACDF BCDF ABCDF ABCEF CDEF ACDEF BCDEF ABCDEF

包含所有可能候选键的输出:ABCF CDF


在上面的示例中,您如何从该组超级键中获取可能的候选键输出?我不明白如何得到这个结果,请帮忙。

【问题讨论】:

    标签: database candidate-key


    【解决方案1】:

    从所有可能的键和超键的集合中找到所有候选键的非常简单的算法如下(伪代码):

    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
    

    在循环结束时,集合K 将包含预期的结果。

    【讨论】:

      猜你喜欢
      • 2011-04-30
      • 1970-01-01
      • 2012-05-21
      • 1970-01-01
      • 1970-01-01
      • 2012-01-04
      • 2012-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多