我试图了解如何找到最少的密钥。该作业为我提供了以下任务:
找到 3 个相关的最小键(每个键是一组属性)。
R (a, b, c, d, e)
a -> b
bc -> d
de -> a
答案是:
(a, c, e)
(b, c, e)
(d, c, e)
我不明白如何得到答案。我将不胜感激任何指导。
我试图了解如何找到最少的密钥。该作业为我提供了以下任务:
找到 3 个相关的最小键(每个键是一组属性)。
R (a, b, c, d, e)
a -> b
bc -> d
de -> a
答案是:
(a, c, e)
(b, c, e)
(d, c, e)
我不明白如何得到答案。我将不胜感激任何指导。
首先,格里菲斯大学的这个网站帮助很大(他们还逐步展示了 BNCF 标准化)。
显然,在这个任务中,最小键是候选键。
第一步是找到存在于关系 R 中但不存在于 RightHandSide 的属性。
(a b c d e) - (b d a) = c e (Relation R - RHS)
第二步是找到当前候选键的闭包。{ce} 的闭包是 {ce}。这无济于事,因此我们需要包含一个额外的属性。我们从(alhabetical)开始:
Closure of {c e a} = { c e a b d } Found one candidate key!
Closure of {c e b} = { c e b d a } Found another candidate key!
We skip the c as it is already in the candidate key.
Closure of {c e d} = { c e d a b } Found the last candidate key! (the task was to find 3)