简体   繁体   English

查找候选键/超级键

[英]Finding Candidate Keys / Superkeys

I am working on another question here and it asks for the candidate keys and the superkeys. 我在这里处理另一个问题,它询问候选键和超级键。 I believe I have the correct candidate keys, but if someone could verify that would be great. 我相信我有正确的候选密钥,但是如果有人可以验证那将是不错的选择。 I am also just having trouble finding superkeys. 我也很难找到超级键。 I don't know if there is a general formula to find them or whatnot. 我不知道是否有找到它们的通用公式。

Here is the question: 这是问题:

Relation Schema: U(A,B,C,D)

FD's: 

A-->B

B-->C

C-->D

D-->A

I found the Candidate keys to be: {A},{B},{C},{D}. 我发现候选键为:{A},{B},{C},{D}。 If someone could verify if this is correct, I would greatly appreciate it. 如果有人可以验证这是否正确,我将不胜感激。 Also if you could let me know how to find the superkeys of this, that would be great. 另外,如果您可以让我知道如何找到它的超级键,那将很棒。 I am not looking directly for the answers, I just want to know if my answer for the candidate keys is correct and how to find the superkeys for this and possibly other questions (if there is a generic way to find them). 我不是直接在寻找答案,我只是想知道我对候选键的答案是否正确,以及如何找到该键以及其他问题(如果有通用的查找方法)的超级键。

Hope someone can help. 希望有人能帮忙。 Will rate best answer once someone helps me figure this out. 一旦有人帮助我解决这个问题,它将给出最佳答案。

Cheers everyone. 欢呼大家。

Let me explain how to find candidate keys in a simple manner: 让我解释一下如何以一种简单的方式查找候选键:

Form a three columns, left,right and middle 形成三列, 左,右和中间

In left column,add the attributes which appear only on left hand side of FD 在左列中,添加仅出现在FD 左侧的属性

In right column,add attributes which appear only on right hand side of FD 在右列中,添加仅出现在FD 右侧的属性

In middle column,add attributes which appear both on right and left hand side of FD 在中间一列,其中加在FD的右侧和左侧出现两个属性

Explanation: 说明:

Attributes on left column indicates,every possible candidate keys must include these attributes 左列的属性表示,每个可能的候选键都必须包含这些属性

and

Attributes on right column indicates candidate keys should not include it 右列的属性指示候选键不应包含它

and

Attributes on middle may or may not be included in super keys 中间键上的属性可以或可以不包含在超级键中

In the given example, All the attributes come under middle column 在给定的示例中,所有属性都位于中间列下

Then,apply Closure property , 然后,应用Closure属性

A+=ABCD A + = ABCD

since 以来

A->A Reflexivity rule A-> A 自反规则

A->B given 给定 A-> B

A->C Transitivity rule A->B and B->C A-> C 及物性规则 A-> B和B-> C

A->D Transitivity rule A->B and B->C and C->D A-> D 及物性规则 A-> B和B-> C和C-> D

Similarly,we can show other keys also as Candidate keys. 同样,我们也可以将其他键显示为候选键。

Super keys are nothing but a superset of candidate keys and non-prime attributes 超级键不过是候选键和非素数属性的超集

Thus,your answer is right 因此,您的答案是正确的

And super keys of this relation is a super set of candidate keys,therefore 这个关系的超级键是候选键的超集,因此

Super keys are AB , AC , ABC and so on. 超级键是ABACABC等。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM