Second normal form explained

Second normal form (2NF), in database normalization, is a normal form. A relation is in the second normal form if it fulfills the following two requirements:

  1. It is in first normal form.
  2. It does not have any non-prime attribute that is functionally dependent on any proper subset of any candidate key of the relation (i.e. it lacks partial dependencies). A non-prime attribute of a relation is an attribute that is not a part of any candidate key of the relation.

Put simply, a relation (or table) is in 2NF if:

  1. It is in 1NF and has a single attribute unique identifier (UID)(in which case every non key attribute is dependent on the entire UID), or
  2. It is in 1NF and has a multi-attribute unique identifier, and every regular attribute (not part of the UID) is dependent on all attributes in the multi-attribute UID, not just one attribute (or part) of the UID.

If any regular (non-prime) attributes are predictable (dependent) on another (non-prime) attribute, that is addressed in third normal form.

History

The second normal form was originally defined by E. F. Codd in 1971.[1]

Decomposition of 1NF into 2NF

To make a 1NF relation a 2NF relation, remove the functionally dependent attributes in the partial dependencies of the first normal form relation, and place those partial dependency dependent attributes in a relation where their corresponding determinant attributes are an entire candidate key.

Example

The following relation does not satisfy 2NF because:

In other words, since is a non-prime attribute functionally dependent on a proper subset of a candidate key, the relation is in violation of 2NF.

Electric toothbrush models! Manufacturer !! Model !! Manufacturer country
ForteX-PrimeItaly
ForteUltracleanItaly
Dent-o-FreshEZbrushUSA
BrushmasterSuperBrushUSA
KobayashiST-60Japan
HochToothmasterGermany
HochX-PrimeGermany

To make the design conform to 2NF, it is necessary to have two relations. To create these relations:

  1. Remove the functionally dependent attributes in the partial dependencies of the first normal form relation. In this example, is the functionally dependent attribute which will be removed.
  2. Place those partial dependency-dependent attributes (i.e.) in a relation where their corresponding determinant attributes are a candidate key (i.e.).

As seen below, is removed from the original table:

Electric toothbrush models! Manufacturer !! Model
ForteX-Prime
ForteUltraclean
Dent-o-FreshEZbrush
BrushmasterSuperBrush
KobayashiST-60
HochToothmaster
HochX-Prime

As seen below, the partial dependency is put into a new relation where the dependency can exist without being a partial dependency:

Electric toothbrush manufacturers! Manufacturer !! Manufacturer country
ForteItaly
Dent-o-FreshUSA
BrushmasterUSA
KobayashiJapan
HochGermany

See also

Further reading

. Christopher J. Date . 2004 . Introduction to Database Systems . 8th . Addison-Wesley . Boston . 978-0-321-19784-9 . registration .

External links

Notes and References

  1. Codd, E. F. "Further Normalization of the Data Base Relational Model". (Presented at Courant Computer Science Symposia Series 6, "Data Base Systems", New York City, May 24–25, 1971.) IBM Research Report RJ909 (August 31, 1971). Republished in Randall J. Rustin (ed.), Data Base Systems: Courant Computer Science Symposia Series 6. Prentice-Hall, 1972.