最小覆盖 FD

Minimal cover FD

我有以下练习文本:

Stack Overflow is a community where users (US), with a specific number of years of experience (Ye), can ask questions and give answers. Based on the given answers, each user earns a reputation (Re) and a badge (Ba), a sort of medal (e.g., bronze, silver and gold badge). The number of years of experience starts from the registration date (Da) on Stack Overflow. Each user can gain some money (Mo) by answering a question. Please note that the description above is not referring to the real Stack Overflow, but it’s useful to define the following exercise. The following FDs are satisfied:

  1. Each user has a specific number of years of experience and a specific badge
  2. The years of experience uniquely determine the user’s reputation and the amount of money for each answer
  3. For each user and for each reputation is defined a unique badge
  4. The registration date determines a single value of years of experience
  5. Each user earns a specific amount of money for each answer

我定义的FD有以下几个:

  1. 野巴 -> 美国
  2. 叶 -> ReMo
  3. Ba -> USRe
  4. 大 -> 叶
  5. 莫 -> 美国

我不确定第三个和最后一个。第三个不知道我写的对不对,还是一定有两个FD(Ba -> US, Ba -> Re)。对于最后一个,我不确定如何表示它,因为句子没有准确说明我写的内容,我认为这是错误的,因为它要求我应用最小覆盖,而对于这些 FD,这是不可能的。

函数依赖性 X → Y 表示属性集 Y 的值是根据属性集 X 的值以唯一方式确定的事实。换句话说,对于 X 值的每个组合,都有一个独特的、特定的 Y.

值组合

让我们检查一下练习中描述的事实。

  1. Each user has a specific number of years of experience and a specific badge

您用依赖项表示了这个事实:

  1. Ye Ba → US

但这恰恰相反。对于上面的 FD,实际上,您是说给定多年的经验和特定的徽章,只有一个用户具有这样的年限和徽章,但在现实中,不同的用户可能具有相同的年限经验和徽章。句子指定的事实可以用 FD 来表示:

1. US → Ye Ba

也就是说,每个用户确定(具有唯一的)多年经验和一枚徽章。

让我们看看其他事实:

  1. The years of experience uniquely determine the user’s reputation and the amount of money for each answer
2. Ye → Re Mo

(这是正确的)

  1. For each user and for each reputation is defined a unique badge

这有点模棱两可,正如评论中指出的那样,徽章可能仅由声誉决定,但如果我们按照规范编写与其对应的 FD,我们可以这样写:

3. US Re → Ba

(反之亦然),当我们计算最小覆盖时,这将得到简化。

  1. The registration date determines a single value of years of experience
4. Re → Ye

(正确)

  1. Each user earns a specific amount of money for each answer
5. US → Mo

同样,用户赚取了一定的、特定的金额(反之亦然,因为这意味着对于一定数量的赚取的钱,只有一个用户可以赚取)。

所以我们现在有依赖项:

US → Ye Ba
Ye → Re Mo
US Re → Ba
Re → Ye
US → Mo

我们可以从中计算出最小覆盖。这是一个可能的计算(请注意,总是 可以从 any 组依赖项计算最小覆盖。

首先我们用右边的单个属性转换依赖关系:

Re US → Ba
Re → Ye
US → Ba
US → Ye
US → Mo
Ye → Mo
Ye → Re

Re US → Ba 中,Re{US}+ = (Ba Mo Re US Ye) 无关。所以我们用US → Ba(已经存在)替换这个依赖。

从剩余的依赖中,我们现在可以删除多余的依赖:

US → Mo

这是因为我们有 US → Ye 和 Ye → Mo.

因此,最后一组依赖项(最小覆盖)是:

Re → Ye
US → Ba
US → Ye
Ye → Mo
Ye → Re