關係數據庫設計的第五範式 (5NF),又稱投影-連接範式(project-join normal form,PJ/NF)是數據庫規範化的一個級別,以去除多個關係之間的語義相關。一張滿足第五範式當且僅當它的每個連接依賴英語join dependency可由候選鍵推出。

R連接依賴英語join dependency於 *{A, B, … Z},定義為A, B, … Z都是R的屬性的子集,且A, B, … Z的連接(join)等於R。R上的連接依賴英語join dependency *{A, B, … Z}可由R的候選鍵推出,當且僅當A, B, …, Z的每一個都包含了R的超鍵[1]

表T滿足第五範式意味着它不能被無損分解為幾個更小的表。分解後的每個小表與表T擁有相同的候選鍵的情形被排除不予考慮(作為平凡情形)。

第五範式於1979年由Ronald Fagin英語Ronald Fagin在會議論文Normal forms and relational database operators中首次提出。[2]

例子 編輯

考慮下例:

Traveling Salesman Product Availability By Brand
(上門推銷員的商品品牌與類型)
Traveling Salesman(上門推銷員) Brand(品牌) Product Type(產品類型)
Jack Schneider Acme Vacuum Cleaner
Jack Schneider Acme Breadbox
Mary Jones Robusto Pruning Shears
Mary Jones Robusto Vacuum Cleaner
Mary Jones Robusto Breadbox
Mary Jones Robusto Umbrella Stand
Louis Ferguson Robusto Vacuum Cleaner
Louis Ferguson Robusto Telescope
Louis Ferguson Acme Vacuum Cleaner
Louis Ferguson Acme Lava Lamp
Louis Ferguson Nimbus Tie Rack

三列共同組成了主鍵。該表也滿足第四範式,因為不存在多值依賴:沒有列(顯然該列自身不是候選鍵)可由其它兩列確定。

如果沒有任何規則限制上門推銷員、品牌、產品類型的組合,那麼上述三個屬性的表對描述這些數據是必須的。但是,如果假定存在下述規則:如果上門推銷員經營某個品牌與某個產品類型,那麼該推銷員必須經營該品牌製造的該產品類型的商品。這種情形下,可以把上表分為三個表:

Product Types By Traveling Salesman
(上門推銷員的產品類型)
Traveling Salesman(上門推銷員) Product Type(產品類型)
Jack Schneider Vacuum Cleaner
Jack Schneider Breadbox
Mary Jones Pruning Shears
Mary Jones Vacuum Cleaner
Mary Jones Breadbox
Mary Jones Umbrella Stand
Louis Ferguson Telescope
Louis Ferguson Vacuum Cleaner
Louis Ferguson Lava Lamp
Louis Ferguson Tie Rack
Brands By Traveling Salesman
(上門推銷員的品牌)
Traveling Salesman(上門推銷員) Brand(品牌)
Jack Schneider Acme
Mary Jones Robusto
Louis Ferguson Robusto
Louis Ferguson Acme
Louis Ferguson Nimbus
Product Types By Brand
(品牌生產的產品類型)
Brand(品牌) Product Type(產品類型)
Acme Vacuum Cleaner
Acme Breadbox
Acme Lava Lamp
Robusto Pruning Shears
Robusto Vacuum Cleaner
Robusto Breadbox
Robusto Umbrella Stand
Robusto Telescope
Nimbus Tie Rack

在這種情形下,上門推銷員Louis Ferguson不可能拒絕銷售由ACME製造的真空吸塵器(Vacuum Cleaner),如果他推銷Acme的其它類型的產品也推銷其它品牌的真空吸塵器。

注意這種方式是如何去除數據冗餘。假設經營麵包箱英語Breadbox與真空吸塵器的上門推銷員Jack Schneider開始新增銷售Robusto品牌。在最初的那張表中,需要增加兩行: (<Jack Schneider, Robusto, Breadboxes>, <Jack Schneider, Robusto, Vacuum Cleaners>)。而在分解後的三張表的設計中,僅需要在表「Brands By Traveling Salesman」中增加一行:(<Jack Schneider, Robusto>)。

用途 編輯

僅在很少情況下滿足第四範式的表可能會不滿足第五範式。這發生在複雜的真實世界的約束限定了屬性的有效組合,但不能在滿足第四範式的表的結構中體現出來。這種表如果不能規範化為第五範式,就需要應用程序通過插入、修改、刪除等操作來維護表中的數據的邏輯一致性。相反,滿足第五範式的表的設計排除了這種不一致性。

參見 編輯

參考文獻 編輯

  1. ^ Analysis of normal forms for anchor-tables (PDF). [2017-02-25]. (原始內容 (PDF)存檔於2016-12-03). 
  2. ^ S. Krishna. Introduction to Data Base and Knowledge Base Systems. 1991. ISBN 9810206208. The fifth normal form was introduced by Fagin 

進一步閱讀 編輯