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.
| Concept | Meaning | Role in 2NF |
|---|---|---|
| Candidate key | Minimal set of columns that identifies a row | Defines what whole key means |
| Composite key | Candidate key with two or more columns | Only case where 2NF can be violated |
| Prime attribute | Column that belongs to some candidate key | Exempt from the 2NF rule |
| Non-prime attribute | Column outside every candidate key | Must depend on the full key |
| Partial dependency | Dependency on part of a composite key | The defect 2NF eliminates |
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.
| Anomaly | What happens | Consequence |
|---|---|---|
| Update anomaly | A product rename must change every order line | Missed rows create inconsistent names |
| Insertion anomaly | A new product cannot be stored without an order | Catalog data depends on sales data |
| Deletion anomaly | Deleting the last order line removes the product | Facts disappear unintentionally |
| Redundancy | Product details repeat on every line | Storage grows and integrity weakens |
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.
- List all candidate keys and identify the composite ones.
- Record the functional dependencies for each non-prime attribute.
- Find attributes that depend on only part of a composite key.
- Move each such group into a table keyed by that key part.
- 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.
| Table | Key | Non-key columns |
|---|---|---|
| OrderLine | (order_id, product_id) | quantity |
| Product | product_id | product_name, unit_price |
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 form | Main requirement | Defect removed |
|---|---|---|
| First normal form | Atomic values, no repeating groups | Multivalued cells and lists |
| Second normal form | Full dependency on every candidate key | Partial dependencies |
| Third normal form | No transitive dependency on a key | Non-key facts about non-key columns |
| Boyce–Codd normal form | Every determinant is a superkey | Remaining key-related anomalies |
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.