第四正規化

第四正規化(4NF)是資料庫正規化中所使用的一種正規形式,是BC范式之后的另一层次的规范化。第二范式、第三范式、BC范式关注于属性集合之间的函数依赖;而第四范式关注更一般形式称作多值依赖

Ronald Fagin于1977年提出。 数据库的一个表遵从第四范式,当且仅当对于任意一个非平凡的多值依赖X Y, X是一个超键[1]

多值依赖

关系数据库的一个表中的列头分为不相交的三组:X, Y, Z。在一行的特定上下文中,称上述列组的数据值为x, y, z多值依赖X Y,意味着如果选择表中的任何值x(记作xc),从而确定该表中所有的xcyz列表,如果xc关联着同一个y的值,不论z的任何取值。实质上,z的存在不提供任何信息能约束到y的可能值。也可以表述为,定义域的每一个值,都能确定值域中的一个值的集合。

平凡多值依赖 X Y是或者YX的子集,或者XY一起形成了该关系的整个属性集合。

函数依赖是多值依赖的特例。函数依赖XY,那么每个x确定了确切一个y值,而不能是多个。

例子

考虑下述例子:

Pizza Delivery Permutations(披薩配貨組合)
Restaurant(餐廳)Pizza Variety(披薩口味)Delivery Area(配貨地區)
A1 PizzaThick CrustSpringfield
A1 PizzaThick CrustShelbyville
A1 PizzaThick CrustCapital City
A1 PizzaStuffed CrustSpringfield
A1 PizzaStuffed CrustShelbyville
A1 PizzaStuffed CrustCapital City
Elite PizzaThin CrustCapital City
Elite PizzaStuffed CrustCapital City
Vincenzo's PizzaThick CrustSpringfield
Vincenzo's PizzaThick CrustShelbyville
Vincenzo's PizzaThin CrustSpringfield
Vincenzo's PizzaThin CrustShelbyville

每一行指出一家饭店能提供一种披萨与一个配货地区。

该表没有非键属性,因为它仅有的键是{Restaurant, Pizza Variety, Delivery Area}。因此,它满足到BC范式为止的所有范式。如果假设,饭店提供的披萨种类与配货地区无关。也即饭店为所有的供货地区提供它能制作的所有披萨类型。那么,这个表不满足第四范式。因为这个表在{Restaurant}属性(它不是超键)上提供了两个非平凡的多值依赖:

  • {Restaurant} {Pizza Variety}
  • {Restaurant} {Delivery Area}

这些在一个非超键上的非平凡多值依赖说明了饭店提供的披萨的多样性独立于饭店的供货地区。这导致了该表中的数据冗余:例如,A1 Pizza供货 Stuffed Crust就重复了3遍;如果A1 Pizza开始生产Cheese Crust pizzas那么向表中增加多行,A1 Pizza的每个供货地区都需要一行。这就可能在给A1 Pizza的每个供货地区增加一行Cheese Crust披萨时,遗漏了一个供货地区,从而导致不满足于多值依赖{Restaurant} {Pizza Variety}。

为了避免上述的错误发生,需要把披萨的多样性与供货地区放置在不同的表中,产生了两张满足第四范式的表:

Varieties By Restaurant
RestaurantPizza Variety
A1 PizzaThick Crust
A1 PizzaStuffed Crust
Elite PizzaThin Crust
Elite PizzaStuffed Crust
Vincenzo's PizzaThick Crust
Vincenzo's PizzaThin Crust
Delivery Areas By Restaurant
RestaurantDelivery Area
A1 PizzaSpringfield
A1 PizzaShelbyville
A1 PizzaCapital City
Elite PizzaCapital City
Vincenzo's PizzaSpringfield
Vincenzo's PizzaShelbyville

如果披萨的种类随着供货地区不同而变化,那么最初的三列的表就满足第四范式。

Ronald Fagin证明总是能够满足第四范式。[2] Rissanen's theorem总是适用于多值依赖

参见

  • 属性值系统

参考文献

  1. "A relation schema R* is in fourth normal form (4NF) if, whenever a nontrivial multivalued dependency X Y holds for R*, then so does the functional dependency X → A for every column name A of R*. Intuitively all dependencies are the result of keys." Fagin, Ronald. (PDF). ACM Transactions on Database Systems. September 1977, 2 (1): 267. doi:10.1145/320557.320571. (原始内容 (PDF)存档于2007-11-29).
  2. Fagin, p. 268

进一步阅读



This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.