Professional Documents
Culture Documents
This applies only to designs that include one-to-many and many-to-many relationships. An example of a one-to-many
relationship is that one kennel can hold many puppies. An example of a many-to-many relationship is that a puppy
can know many tricks and several puppies can know the same tricks.
Fourth normal form (4NF) is a normal form used in database normalization. Introduced by
Ronald Fagin in 1977, 4NF is the next level of normalization after Boyce-Codd normal form
(BCNF). Whereas the second, third, and Boyce-Codd normal forms are concerned with
functional dependencies, 4NF is concerned with a more general type of dependency known as a
multivalued dependency. A table is in 4NF if and only if, for every one of its non-trivial
multivalued dependencies X →→ Y, X is a superkey—that is, X is either a candidate key or a
superset thereof.[1]
Contents
[hide]
1 Multivalued dependencies
2 Example
3 4NF in practice
4 See also
5 References
6 Further reading
[edit] Example
Consider the following example:
Each row indicates that a given restaurant can deliver a given variety of pizza to a given area.
The table has no non-key attributes because its only key is {Restaurant, Pizza Variety, Delivery
Area}. Therefore it meets all normal forms up to BCNF. If we assume, however, that pizza
varieties offered by a restaurant are not affected by delivery area, then it does not meet 4NF. The
problem is that the table features two non-trivial multivalued dependencies on the {Restaurant}
attribute (which is not a superkey). The dependencies are:
These non-trivial multivalued dependencies on a non-superkey reflect the fact that the varieties
of pizza a restaurant offers are independent from the areas to which the restaurant delivers. This
state of affairs leads to redundancy in the table: for example, we are told three times that A1
Pizza offers Stuffed Crust, and if A1 Pizza starts producing Cheese Crust pizzas then we will
need to add multiple rows, one for each of A1 Pizza's delivery areas. There is, moreover, nothing
to prevent us from doing this incorrectly: we might add Cheese Crust rows for all but one of A1
Pizza's delivery areas, thereby failing to respect the multivalued dependency {Restaurant} →→
{Pizza Variety}.
To eliminate the possibility of these anomalies, we must place the facts about varieties offered
into a different table from the facts about delivery areas, yielding two tables that are both in 4NF:
Varieties By
Delivery Areas By
Restaurant
Restaurant
Pizza
Restaurant Delivery
Variety Restaurant
Area
Thick
A1 Pizza A1 Pizza Springfield
Crust
A1 Pizza Shelbyville
Stuffed
A1 Pizza Capital
Crust A1 Pizza
City
Thin
Elite Pizza Capital
Crust Elite Pizza
City
Stuffed
Elite Pizza Vincenzo's
Crust Springfield
Pizza
Vincenzo's Thick
Pizza Crust Vincenzo's
Shelbyville
Pizza
Vincenzo's Thin
Pizza Crust
In contrast, if the pizza varieties offered by a restaurant sometimes did legitimately vary from
one delivery area to another, the original three-column table would satisfy 4NF.
Ronald Fagin demonstrated that it is always possible to achieve 4NF.[2] Rissanen's theorem is
also applicable on multivalued dependencies.
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 semantically related multiple relationships. A table is said to be in the
5NF if and only if every 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]
Contents
[hide]
1 Example
o 1.1 Usage
2 See also
3 References
4 Further reading
[edit] Example
Consider the following example:
The table's predicate is: Products of the type designated by Product Type, made by the brand
designated by Brand, are available from the travelling salesman designated by Travelling
Salesman.
In the absence of any rules restricting the valid possible combinations of Travelling 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 Travelling Salesman has certain Brands
and certain Product Types in his repertoire. If Brand B is in his repertoire, and Product Type P
is in his repertoire, then (assuming Brand B makes Product Type P), the Travelling Salesman
must offer products of Product Type P made by Brand B.
Product Types By Travelling Salesman Brands By Travelling Salesman Product Types By Brand
Travelling Salesman Product Type Travelling Salesman Brand Brand Product Type
Jack Schneider Vacuum Cleaner Jack Schneider Acme Acme Vacuum Cleaner
Willy Loman Pruning Shears Louis Ferguson Robusto Acme Lava Lamp
Willy Loman Vacuum Cleaner Louis Ferguson Acme Robusto Pruning Shears
Willy Loman Breadbox
Robusto Vacuum Cleaner
Willy Loman Umbrella Stand
Robusto Breadbox
Louis Ferguson Telescope
Louis Ferguson Nimbus Robusto Umbrella Stand
Louis Ferguson Vacuum Cleaner
Robusto Telescope
Louis Ferguson Lava Lamp
Nimbus Tie Rack
Louis Ferguson Tie Rack
Note how this setup helps to remove redundancy. Suppose that Jack Schneider starts selling
Robusto's products. In the previous setup we would have to add two new entries since Jack
Schneider is able to sell two Product Types covered by Robusto: Breadboxes and Vacuum
Cleaners. With the new setup we need only add a single entry (in Brands By Travelling
Salesman).
[edit] Usage
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.