gpt4 book ai didi

database - 关系数据库中的 BCNF/3NF

转载 作者:搜寻专家 更新时间:2023-10-30 20:12:10 26 4
gpt4 key购买 nike

如何判断关系 R 是否属于 BCNF 和 3NF?

我正在阅读一本教科书,它告诉我您正在查看 3 个主要属性,但我无法理解他们在说什么,或者至少在给定时应用他们在说什么关系和 FD。

3个属性:给定具有属性 A 的关系 R,X 是 R 属性的子集,对于 F 中的每个 FD X⟶A,以下陈述之一为真:

  • A∈X;也就是说,它是一个平凡的 FD(∈ 意思是“在 X 中找到”)
  • X 是一个 super 键
  • A 是 R 的某个 key 的一部分

前两个对应 BCNF,3NF 包括第三个。

最佳答案

SQL Antipatterns by Bill Karwin 一书在第 303 页有一个关于 BCNF 和 3NF 的很好的例子,它有点复杂,但我相信比我目前读到的任何差异描述都更简洁地指出了差异。

For example, suppose we have three tag types: tags that describe the impact of the bug, tags for the subsystem the bug affects, and tags that describe the fix for the bug. We decide that each bug must have at most one tag of a specific type. Our candidate key could be bug_id plus tag, but it could also be bug_id plus tag_type. Either pair of columns would be specific enough to address every row individually.

bug_id tag      tag_type
------------------------
1234 crash impact
3456 printing subsystem
3456 crash impact
5678 report subsystem
5678 crash impact
5678 data fix

然后本书将这个满足 3NF 的单表更改为满足 BCNF 的两个表:

bug_id tag
----------
1234 crash
3456 printing
3456 crash
5678 report
5678 crash
5678 data

tag tag_type
------------------
crash impact
printing subsystem
report subsystem
data fix

关于database - 关系数据库中的 BCNF/3NF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7781548/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com