考虑关系方案 R = {E, F, G, H, I, J, K, L, M, M} 和函数依赖集 {{E, F} -> {G}, {F} -> {I, J}, {E, H} -> {K, L}, K -> {M}, L -> {N} 在 R 上。R 的键是什么?
(A) {E, F}
(B) {E, F, H}
(C) {E, F, H, K, L}
(D) {E}答案:(乙)
说明:所有属性都可以从 {E, F, H} 导出
要解决 GATE 论文中经常问到的这类问题,请尝试使用快捷方式来解决,这样可以节省足够的时间。
拳法:
使用给定的选项尝试获得每个选项的关闭。解决方案是包含 R 和最小超级密钥的解决方案,即候选密钥。
A) {EF}+ = {EFGIJ} ≠ R(The given relation)
B) {EFH}+ = {EFGHIJKLMN} = R (Correct since each member of the
given relation is determined)
C) {EFHKL}+ = {EFGHIJKLMN} = R (Not correct although each member
of the given relation can be determined
but it is not minimal, since by the definition
of Candidate key it should be minimal Super Key)
D) {E}+ = {E} ≠ R
第二种方法:
Since, {EFGHIJKLMN}+ = {EFGHIJKLMN}
{EFGHIJKLM}+ = {EFGHIJKLMN} ( Since L -> {N}, hence can replace N by L)
In a similar way K -> {M} hence replace M by K
{EFGHIJKL}+ = {EFGHIJKLMN}
Again {EFGHIJ}+ = {EFGHIJKLMN} (Since {E, H} -> {K, L}, hence replace KL by EH)
{EFGH}+ = {EFGHIJKLMN} (Since {F} -> {I, J} )
{EFH}+ = {EFGHIJKLMN} (Since {E, F} -> {G} )
此解释由Manish Rai 提供。
在此处了解更多信息:
使用函数依赖查找属性闭包和候选键这个问题的测验