简体   繁体   English

关系数据库中的BCNF / 3NF

[英]BCNF/3NF in Relational Databases

How do you tell if a relation R is in BCNF and 3NF? 您如何确定关系R是否存在于BCNF和3NF中?

I'm reading a textbook, and it's telling me that there are 3 main attributes you're looking at, but I'm having trouble understanding what they're saying, or at least applying what they're saying when given a relation and FD's. 我正在读一本教科书,它告诉我,您正在查看3个主要属性,但我无法理解他们在说什么,或者至少在给予某种关系时应用他们在说什么,并且FD的。

The 3 attributes: Given a relation R with the attribute A, and X a subset of attributes of R, for every FD X⟶A in F, one of the following statements is true: 这3个属性:对于F中的每个FD X,A,给定具有属性A的关系R,以及X的R属性的子集,以下陈述之一为真:

  • A ∈ X; A∈X; that is, it is a trivial FD (∈ meaning "is found in X") 也就是说,它是一个琐碎的FD(∈表示“在X中找到”)
  • X is a superkey X是超键
  • A is part of some key for R A是R的某些键的一部分

The top two correspond to BCNF, and 3NF's include the third. 前两个对应于BCNF,而3NF包含第三个。

The book SQL Antipatterns by Bill Karwin has a nice example about BCNF and 3NF on page 303 that is a little complicated but I believe points out the difference more succinctly than any description of the difference I've read so far. Bill Karwin撰写的《 SQL Antipatterns 》一书在第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 . 我们的候选密钥可以是bug_id加上tag ,但是也可以是bug_id加上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 

The book then changes this single table (which satisfies 3NF) into two tables that satisfy BCNF: 然后,该书将这个单一表(满足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 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM