查找关系的主键

时间:2015-08-21 07:19:08

标签: database relational-database

我遇到了这个问题。

找到关系R(A,B,C,D,E,F,G,H,I)的主键,其中:

A -> B,C
E -> F
D -> I
A,D -> G
G -> H

谢谢

1 个答案:

答案 0 :(得分:0)

(唯一)键是A, D, E,事实上,如果你计算闭包,你会得到:

1. (A,D,E)+ = A,D,E
2. You add B,C for the first dependence, so now (A,D,E)+ = A,D,E,B,C
3. You add F for the second dependence, so now (A,D,E)+ = A,D,E,B,C,F
4. You add I for the third dependence, so now (A,D,E)+ = A,D,E,B,C,F,I
5. You add G for the fourth dependence, so now (A,D,E)+ = A,D,E,B,C,F,I,G
6. And finally you add H for the last dependence, so that (A,D,E)+ = A,D,E,B,C,F,I,G,H

由于A,D,E确定所有属性,因此它是一个关键。为了证明这是唯一的关键,请注意A,D,E的属性不出现在函数依赖的右侧,因此所有属性都必须属于一个键。由于它们形成了一个键,因此不存在其他(候选)键。

相关问题