经验法则:
An Attribute appearing only on the left hand side in your FDs is in all keys.
An Attribute not appearing in any of your FDs is in all keys.
An Attribute only appearing on the right hand side in your FDs is not in any key.
A candidate key is the left hand side of a derived FD on which all attributes depend.
例子:
R(ABCDE), (A->C, AB->D, D->B)
E 不会出现在任何 FD 中。E 在所有键中。A 仅出现在左侧。A 在所有键中。C 只出现在右手边。C 不在任何键中。
键将包括以下属性:
AE
使用来自 AE 的每个可能的键查找依赖项:
A->C
A->AC (X->XY axiom)
E->E
AE->ACE (from previous 2 FDs)
并非所有属性都在右侧,因此 AE 不是键,只是所有键的一部分。
开始将 AE 与 BCD 结合起来,看看会发生什么:
ADE->ABCDE (as D->B, and by X->XY axiom D->BD. This is a key, by last rule of thumb)
ACE->ACE
ABE->ABCDE (AE->ACE, B->BD from axioms, this is a key)
ABCE->ABCDE, ABDE->ABCDE (superkeys of ABE, so ignore)
ACDE->ABDCE (superkey of ADE)
假设我做对了,那么 ABE 和 ADE 是关键。