我正在解决另一个问题,它要求提供候选键和 super 键。我相信我有正确的候选 key ,但如果有人可以验证那就太好了。我也很难找到 super key 。我不知道是否有找到它们的通用公式或诸如此类的东西。
问题是:
Relation Schema: U(A,B,C,D)
FD's:
A-->B
B-->C
C-->D
D-->A
我发现候选键为:{A}、{B}、{C}、{D}。如果有人可以验证这是否正确,我将不胜感激。另外,如果您能让我知道如何找到它的 super 键,那就太好了。我不是直接寻找答案,我只是想知道我对候选键的答案是否正确,以及如何找到这个问题和可能的其他问题的 super 键(如果有找到它们的通用方法)。
希望有人能帮忙。一旦有人帮助我解决这个问题,我就会评价最佳答案。
大家干杯。
最佳答案
让我解释一下如何以简单的方式查找候选键:
形成三列,左、右、中
In left column,add the attributes which appear only on left hand side of FD
In right column,add attributes which appear only on right hand side of FD
In middle column,add attributes which appear both on right and left hand side of FD
说明:
Attributes on left column indicates,every possible candidate keys must include these attributes
和
Attributes on right column indicates candidate keys should not include it
和
Attributes on middle may or may not be included in super keys
在给定的示例中, 所有属性都位于中间列
下然后,应用闭包属性,
A+=ABCD
自从
A->A Reflexivity rule
A->B given
A->C Transitivity rule A->B and B->C
A->D Transitivity rule A->B and B->C and C->D
类似地,我们也可以将其他键显示为候选键。
super 键只不过是候选键和非素数属性的超集
因此,您的答案是正确
而这种关系的超键是候选键的超集,因此
super 键有AB、AC、ABC等。
希望这有帮助。
关于mysql - 查找候选键/ super 键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30109298/