Finding Candidate Keys / Superkeys

点点圈 提交于 2019-12-22 01:32:43

问题


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}. 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.


回答1:


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

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

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,

A+=ABCD

since

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

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.

Hope this helps.



来源:https://stackoverflow.com/questions/30109298/finding-candidate-keys-superkeys

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!