Second normal form

Also known as: 2NF

On this page 7

Second normal form (2NF) is a level of relational normalization in which a table is already in first normal form and every non-prime attribute depends on the whole of every candidate key, not on just part of one. In data modeling for relational databases, 2NF removes partial dependencies, the redundancy that appears when a table keyed by a composite key stores facts about only one component of that key.

Edgar F. Codd defined 2NF in the early 1970s as a step between first normal form and third normal form. It matters only for tables with composite candidate keys: a table whose every candidate key consists of a single column and that satisfies first normal form is automatically in 2NF.

The formal definition of second normal form

A relation is in second normal form when it satisfies first normal form and contains no partial functional dependency of a non-prime attribute on a candidate key. A functional dependency X → Y means that each value of X determines exactly one value of Y; it is partial when Y already depends on a proper subset of the key.

Two terms carry the definition. A prime attribute belongs to at least one candidate key, and a non-prime attribute belongs to none. 2NF constrains only non-prime attributes, so dependencies among key columns are left to stricter forms such as Boyce–Codd normal form.

ConceptMeaningRole in 2NF
Candidate keyMinimal set of columns that identifies a rowDefines what whole key means
Composite keyCandidate key with two or more columnsOnly case where 2NF can be violated
Prime attributeColumn that belongs to some candidate keyExempt from the 2NF rule
Non-prime attributeColumn outside every candidate keyMust depend on the full key
Partial dependencyDependency on part of a composite keyThe defect 2NF eliminates
Key concepts behind the 2NF definition

A frequent textbook simplification says that attributes must depend on the primary key. The precise rule refers to every candidate key, which matters when a table has several alternative keys.

Partial dependencies and the anomalies they cause

Partial dependencies cause update, insertion and deletion anomalies because one fact is stored many times. Consider a table OrderLine(order_id, product_id, quantity, product_name, unit_price) with the composite key (order_id, product_id), where product_name and unit_price depend only on product_id.

AnomalyWhat happensConsequence
Update anomalyA product rename must change every order lineMissed rows create inconsistent names
Insertion anomalyA new product cannot be stored without an orderCatalog data depends on sales data
Deletion anomalyDeleting the last order line removes the productFacts disappear unintentionally
RedundancyProduct details repeat on every lineStorage grows and integrity weakens
Anomalies in a table that violates 2NF

The root problem is that the table mixes two different subjects: facts about an order line and facts about a product. Normalization separates subjects so that each fact is stored exactly once.

Decomposing a table into 2NF

A table is brought into 2NF by decomposition: each partially dependent attribute moves into a new table together with the key part it depends on. The decomposition must be lossless, meaning a natural join of the new tables reproduces the original rows exactly, and it should preserve dependencies so constraints remain enforceable.

  1. List all candidate keys and identify the composite ones.
  2. Record the functional dependencies for each non-prime attribute.
  3. Find attributes that depend on only part of a composite key.
  4. Move each such group into a table keyed by that key part.
  5. Keep a foreign key from the original table to the new table.

Applied to the order line example, the decomposition produces two tables, linked through referential integrity.

TableKeyNon-key columns
OrderLine(order_id, product_id)quantity
Productproduct_idproduct_name, unit_price
Result of decomposing the order line example

One modeling decision deserves care. The price charged on an order is often a historical fact, not a product attribute, so many designs keep a separate sold_price column in OrderLine. That column depends on the full key and therefore does not violate 2NF.

Second normal form among the other normal forms

2NF is the second step in a cumulative hierarchy: each higher normal form includes all requirements of the lower ones. 2NF eliminates partial dependencies, while third normal form additionally removes transitive dependencies between non-prime attributes.

Normal formMain requirementDefect removed
First normal formAtomic values, no repeating groupsMultivalued cells and lists
Second normal formFull dependency on every candidate keyPartial dependencies
Third normal formNo transitive dependency on a keyNon-key facts about non-key columns
Boyce–Codd normal formEvery determinant is a superkeyRemaining key-related anomalies
How 2NF relates to neighboring normal forms

In practice, designers rarely stop deliberately at 2NF. Operational schemas usually target third normal form or BCNF, and 2NF serves mainly as a diagnostic checkpoint and a teaching step that isolates one class of problem.

Practical considerations and common misconceptions

Surrogate keys often make 2NF look satisfied when it is not. Adding an auto-increment id to the order line table gives a single-column primary key, but (order_id, product_id) remains a candidate key, and the partial dependency of product_name on product_id still exists. A surrogate key hides the problem without solving it.

  • 2NF does not apply to dependencies among prime attributes; those belong to BCNF analysis.
  • Meeting 2NF does not guarantee freedom from redundancy, because transitive dependencies may remain.
  • In dimensional modeling, star schemas intentionally denormalize dimension tables for query speed.
  • Functional dependencies come from business rules, not from sample data, which can mislead.

Denormalization below 2NF is sometimes justified in analytical workloads, but it should be a conscious choice backed by load processes that keep duplicated values consistent.

The simple explanation

Imagine a spreadsheet of school enrollments where each row records a student, a course and a grade, but also repeats the teacher on every row. The teacher belongs to the course, not to the student taking it.

Second normal form says that such information should live in its own table. Every detail in a row must describe the whole row, not just one part of it. Then a teacher change is made once, in one place, instead of on hundreds of rows.

How it is used in practice

A university registrar stores enrollments in a table keyed by (student_id, course_code). The table also contains course_title, credits and department, which depend only on course_code. With about 40,000 enrollments per semester, a single change to a course title had to be written to roughly 300 rows, and an interrupted update left two different titles on transcripts.

During a schema review, the data team identified the partial dependency and moved course_title, credits and department into a Course table keyed by course_code, leaving Enrollment with only grade and enrollment_date. Course data now changes in one row per course, new courses can be registered before anyone enrolls, and transcript reports join the two tables with no measurable slowdown on the indexed keys.