Tuesday, May 20, 2014

Fifth normal form

From: http://en.wikipedia.org/wiki/Fifth_normal_form

Fifth normal form (5NF), also known as project-join normal form (PJ/NF) is a level of database normalization designed to reduce redundancy in relational databases recording multi-valued facts by isolating semanticallyrelated multiple relationships. A table is said to be in the 5NF if and only if every non-trivial join dependency in it is implied by the candidate keys.
A join dependency *{A, B, … Z} on R is implied by the candidate key(s) of R if and only if each of A, B, …, Z is a superkey for R.[1]

Example[edit]

Consider the following example:
Traveling Salesman Product Availability By Brand
Traveling SalesmanBrandProduct Type
Jack SchneiderAcmeVacuum Cleaner
Jack SchneiderAcmeBreadbox
Willy LomanRobustoPruning Shears
Willy LomanRobustoVacuum Cleaner
Willy LomanRobustoBreadbox
Willy LomanRobustoUmbrella Stand
Louis FergusonRobustoVacuum Cleaner
Louis FergusonRobustoTelescope
Louis FergusonAcmeVacuum Cleaner
Louis FergusonAcmeLava Lamp
Louis FergusonNimbusTie Rack
The table's predicate is: Products of the type designated by Product Type, made by the brand designated by Brand, are available from the traveling salesman designated by Traveling Salesman.
In the absence of any rules restricting the valid possible combinations of Traveling Salesman, Brand, and Product Type, the three-attribute table above is necessary in order to model the situation correctly.
Suppose, however, that the following rule applies: A Traveling Salesman has certain Brands and certain Product Types in his repertoire. If Brand B1 and Brand B2 are in his repertoire, and Product Type P is in his repertoire, then (assuming Brand B1 and Brand B2 both make Product Type P), the Traveling Salesman must offer products of Product Type P those made by Brand B1 and those made by Brand B2.
In that case, it is possible to split the table into three:
Product Types By Traveling Salesman
Traveling SalesmanProduct Type
Jack SchneiderVacuum Cleaner
Jack SchneiderBreadbox
Willy LomanPruning Shears
Willy LomanVacuum Cleaner
Willy LomanBreadbox
Willy LomanUmbrella Stand
Louis FergusonTelescope
Louis FergusonVacuum Cleaner
Louis FergusonLava Lamp
Louis FergusonTie Rack
Brands By Traveling Salesman
Traveling SalesmanBrand
Jack SchneiderAcme
Willy LomanRobusto
Louis FergusonRobusto
Louis FergusonAcme
Louis FergusonNimbus
Product Types By Brand
BrandProduct Type
AcmeVacuum Cleaner
AcmeBreadbox
AcmeLava Lamp
RobustoPruning Shears
RobustoVacuum Cleaner
RobustoBreadbox
RobustoUmbrella Stand
RobustoTelescope
NimbusTie Rack

In this case, it's impossible for Louis Ferguson to refuse to offer Vacuum Cleaners made by ACME (assuming ACME makes Vacuum Cleaners) if he sells anything else made by Acme (Lava Lamp) and he also sells Vacuum Cleaners made by any other brand (Robusto).
Note how this setup helps to remove redundancy. Suppose that Jack Schneider starts selling Robusto's products Breadboxes and Vacuum Cleaners. In the previous setup we would have to add two new entries one for each product type (, ). With the new setup we need to add only a single entry ()in Brands By Traveling Salesman.

Usage[edit]

Only in rare situations does a 4NF table not conform to 5NF. These are situations in which a complex real-world constraint governing the valid combinations of attribute values in the 4NF table is not implicit in the structure of that table. If such a table is not normalized to 5NF, the burden of maintaining the logical consistency of the data within the table must be carried partly by the application responsible for insertions, deletions, and updates to it; and there is a heightened risk that the data within the table will become inconsistent. In contrast, the 5NF design excludes the possibility of such inconsistencies.

See also[edit]

References[edit]

Further reading[edit]

No comments: