Third normal form
From Wikipedia, the free encyclopedia
The third normal form (3NF) is a normal form used in database normalization to check if all the non-key attributes of a relation depend only on the candidate keys of the relation. This means that all non-key attributes are mutually independent or, in other words, that a non-key attribute cannot be transitively dependent on another non-key attribute.
The 3NF differs from the second normal form in that all non-key attributes in 3NF are required to be directly dependent on each candidate key of the relation. The 3NF therefore insists, in the words of Bill Kent, that "the relation is based on the key, the whole key and nothing but the key", to which some add "so help me Codd."
Contents |
[edit] Formal definition
Let:
- R be a relation schema,
- F be the set of functional dependencies given to hold over R,
- X be a subset of the attributes of R, and
- A be an attribute of R
R is in third normal form if for every functional dependency of the form one of the following statements is true:
- ; that is, A is a trivial functional dependency , or
- X is a superkey, or
- A is part of some key for R
Any relation with a partial dependency or a transitive dependency violates the third normal form.
[edit] Example
Consider a relation that defines a machine part as follows:
Part number (primary key) |
Manufacturer name | Manufacturer address |
---|---|---|
1000 | Toyota | Park Avenue |
1001 | Mitsubishi | Lincoln Street |
1002 | Toyota | Park Avenue |
In this case, the manufacturer address does not belong on this relation, because it is a fact about the manufacturer of the part, rather than the part itself. The manufacturer address should therefore be moved into a separate table with the attributes:
Manufacturer name (primary key) |
Manufacturer address |
---|---|
Toyota | Park Avenue |
Mitsubishi | Lincoln Street |
...and the original table should be redefined as:
Part number (primary key) |
Manufacturer name |
---|---|
1000 | Toyota |
1001 | Mitsubishi |
1002 | Toyota |
The problem with a table not being in 3NF is that for every manufacturer's name we have to maintain a redundant address (i.e. an address for each part number, rather than one for each manufacturer's name).
Or look at the following example:
Order Number (primary key) |
Customer Number | Unit Price | Quantity | Total |
---|---|---|---|---|
1000 | David | $35.00 | 3 | $105.00 |
1001 | Jim | $25.00 | 2 | $50.00 |
1002 | Bob | $25.00 | 3 | $75.00 |
In this case Total does not belong to the table because Total can be inferred from multiplying Unit Price by Quantity. To comply with 3NF, remove the Total column (in a query, instead of "SELECT Orders.Total FROM Orders", use SELECT UnitPrice * Quantity FROM Orders).
Order Number (primary key) |
Customer Number | Unit Price | Quantity |
---|---|---|---|
1000 | David | $35.00 | 3 |
1001 | Jim | $25.00 | 2 |
1002 | Bob | $25.00 | 3 |
[edit] Sources
- Ramakrishnan, Raghu and Johannes Gehrke. "Schema Refinement and Normal Forms." Database Management Systems, Third Edition. ISBN 0-07-246563-8. McGraw Hill. August 14, 2002.
- Gupta, Gopal. "Third Normal Form (3NF)." Single Valued Normalization. 1996.
[edit] References
- Litt's Tips: Normalization
- Rules Of Data Normalization
- Date, C. J. (1999), An Introduction to Database Systems (8th ed.). Addison-Wesley Longman. ISBN 0-321-19784-4.
- Kent, W. (1983) A Simple Guide to Five Normal Forms in Relational Database Theory, Communications of the ACM, vol. 26, pp. 120-125
- Date, C.J., & Darwen, H., & Pascal, F. Database Debunkings
[edit] External links
- Database Normalization Basics by Mike Chapple (About.com)
- An Introduction to Database Normalization by Mike Hillyer.
- Normalization by ITS, University of Texas.
- A tutorial on the first 3 normal forms by Fred Coulson
- Free PDF poster available by Marc Rettig
- Description of the database normalization basics by Microsoft
- Developing High Quality Data Models
- Generic Data Modeling
- The Gellish Language - A Universal Data Structure
Topics in Database normalization |
First normal form | Second normal form | Third normal form |