找候选键 候选键的判定

找出候选键的方法

First example

WHOSE

  • WH -> S
  • HOS -> E

Steps:

  1. Find the attributes that are neither on the left and right side(找到依赖两侧都没有的属性)

(none)

  1. Find attributes that are only on the right side
    (找到只在依赖右侧出现的属性)

E

  1. Find attributes that are only on the left side
    (找到只在依赖左侧出现的属性)

WHO

  1. Combine the attributes on step 1 and 3
    (把第一步和第三步中找到的属性合并)

since step 1 has no attributes, it’s just WHO

  1. Test if the closures of attributes on step 4 are all the attributes
    (测试第四步中的属性 所形成的回路 是否就是所有属性)

in our case, yes it is. Because with WH we can get S, and by HOS, we can get E.
So we have only one candidate key, that is WHO.

Third example

ABCD

  • ABC -> D
  • D -> A

Steps:

  1. BC
  2. BC
  3. The closure of BC is only BC, we should find the relation exterior.
  4. Find the relation exteriors, that is the attributes not included in step 4 and step 2.

in this example it is AD

  1. Now test the closures of attributes on step 4 + one attribute in step 6 one at a time.

ABC closures are ABCD, so it is a candidate key
BCD closures are ABCD, so it is also a candidate key
so in this case we have two candidate keys, they are ABC and BCD.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容