mysql - 查找候选键/ super 键

标签 mysql sql database relation candidate-key

我正在解决另一个问题,它要求提供候选键和 super 键。我相信我有正确的候选 key ,但如果有人可以验证那就太好了。我也很难找到 super key 。我不知道是否有找到它们的通用公式或诸如此类的东西。

问题是:

Relation Schema: U(A,B,C,D)

FD's: 

A-->B

B-->C

C-->D

D-->A

我发现候选键为:{A}、{B}、{C}、{D}。如果有人可以验证这是否正确,我将不胜感激。另外,如果您能让我知道如何找到它的 super 键,那就太好了。我不是直接寻找答案,我只是想知道我对候选键的答案是否正确,以及如何找到这个问题和可能的其他问题的 super 键(如果有找到它们的通用方法)。

希望有人能帮忙。一旦有人帮助我解决这个问题,我就会评价最佳答案。

大家干杯。

最佳答案

让我解释一下如何以简单的方式查找候选键:

形成三列,左、右、中

In left column,add the attributes which appear only on left hand side of FD

In right column,add attributes which appear only on right hand side of FD

In middle column,add attributes which appear both on right and left hand side of FD

说明:

Attributes on left column indicates,every possible candidate keys must include these attributes

Attributes on right column indicates candidate keys should not include it

Attributes on middle may or may not be included in super keys

在给定的示例中, 所有属性都位于中间

然后,应用闭包属性

A+=ABCD

自从

A->A Reflexivity rule

A->B given

A->C Transitivity rule A->B and B->C

A->D Transitivity rule A->B and B->C and C->D

类似地,我们也可以将其他键显示为候选键。

super 键只不过是候选键和非素数属性的超集

因此,您的答案是正确

而这种关系的超键是候选键的超集,因此

super 键有ABACABC等。

希望这有帮助。

关于mysql - 查找候选键/ super 键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30109298/

相关文章:

MySQL 子字符串搜索(前缀 ID)

Mysql:在子表中插入一个新行,其中包含从父表获取的外键列以外的新值

android - com.android.providers.calendar 是删除已删除的事件还是只是将它们标记为已删除?

mysql - 类似系统的数据库模式

php - 如果 mysql_query 失败则执行多条语句

PHP $_GET 文件无法从 mysql 数据库检索数据

mysql - 为什么我的 sql 查询没有运行,因为我设置了正确的 DELIMITER

java - 如何将 JPA 与随机数据库(即用户提交的)一起使用

PHP PDO 选择名称中带有单引号的列

database - 更新排序列表