BCNF与4NF(第四次标准化)
数据库规范化是一种处理关系数据库管理系统的技术。在规范化良好的数据库中,可以避免数据错误。规范化用于减少数据库的数据冗余。这意味着实现数据库表及其关系,消除冗余和不一致的依赖关系。为规范化设置了一些预定义的规则。这些规则被称为规范形式。
- First Normal Form (1NF)
- Second Normal Form (2NF)
- Third Normal Form (3NF)
- Boyce-Codd Normal Form (BCNF or 3.5NF)
- Fourth Normal Form (4NF)
第一范式被称为表的原子性。表原子性可以通过两个步骤实现。
- Removing duplicate columns from the same table.
- Creating separate tables for related duplicated columns. ( there must be primary keys to identify each row of this tables)
在第二种标准形式中,尝试通过提取表中的冗余数据并将它们放在单独的表中来减少这些数据。这可以通过执行以下步骤来实现。
- Select the data set, which applies to multiple rows, and place them in separate tables.
- Create the relati***hips between these new tables and parent tables using foreign keys.
要将数据库转换为第三范式,必须先实现第一范式和第二范式。当数据库在1NF和2NF中时,没有任何重复的列,也没有任何适用于多行的数据子集。第三种标准形式可以通过删除表的列来实现,这些列不是完全依赖于主键的。
Boyce-Codd标准型(BCNF或3.5NF)
BCNF代表“Boyce-Codd范式”。这种标准形式也称为3.5数据库规范化的标准形式。要实现BCNF,数据库必须已经达到第三标准形式。然后通过以下步骤来实现BCNF。
- Identify all candidate keys in the relati***
- Identify all functional dependencies in the relati***.
- If there are functional dependencies in the relation, where their determinants are not candidate keys for the relation, remove the functional dependencies by placing them in a new relation along with a copy of their determinant.
第四范式
在将数据库规范化为第四个标准格式之前,数据库必须是第三个标准格式。如果数据库已经是第三种正常形式,下一步应该是删除多值依赖项。(如果一个或多个行暗示同一个表中存在一个或多个其他行,则称为多值依赖项。)
BCNF和4NF(第四范式)有什么区别?•数据库必须已经达到3NF才能将其带到BCNF,但数据库必须在3NF和BCNF中,才能达到4NF。•在第四种范式中,表中没有多值依赖关系,但在BCNF中,表中可以有多值依赖数据。 |