Skip to content
Contents/CH 19
Normalization/Advanced · 14 min

Normalization: 2NF

Second normal form removes dependencies on only part of a composite key. If a non-key attribute depends on half the key, it belongs in another table.

In plain English

If a fact belongs to only half of a two-part key, give it its own table.

The one idea

Second normal form removes partial dependencies: a non-key attribute must depend on the whole composite key, not just part of it.

A fact about a course does not belong in every enrollment row. Partial dependencies duplicate that fact once per student.

By the end

  1. 01Identify a composite primary key.
  2. 02Detect a partial dependency.
  3. 03Decompose a relation into 2NF.
  4. 04Explain why 1NF is a prerequisite.
01

The rule

A relation is in 2NF if it is in 1NF and every non-key attribute is fully functionally dependent on the whole primary key. If the primary key is a single attribute, 2NF is automatic. Partial dependencies only matter with composite keys.

02

A partial dependency example

Enrollment(student_id, course_id, student_name, course_name, grade) has primary key (student_id, course_id). student_name depends only on student_id; course_name depends only on course_id. Both are partial dependencies. grade depends on the full key.

chapter-19.db
(student_id, course_id) -> grade     full dependency
student_id -> student_name            partial
course_id  -> course_name             partial
03

Decomposition

Split the partial dependencies into their own relations: Student(student_id, student_name), Course(course_id, course_name), and Enrollment(student_id, course_id, grade). The enrollment table keeps the full-key dependency; the others keep the single-attribute dependencies.

chapter-19.db
Student(student_id, student_name)
Course(course_id, course_name)
Enrollment(student_id, course_id, grade)
Worked example3 steps

Enrollment with course names

Enrollment(student_id, course_id, student_name, course_name, grade) has composite key (student_id, course_id).

01

Check student_name against the key.

It depends only on student_id, so it is a partial dependency.

02

Check course_name against the key.

It depends only on course_id, another partial dependency.

03

Split Student, Course, and Enrollment.

Grade remains in Enrollment because it depends on both parts of the key.

Conclusion2NF is about composite keys. If a relation has a single-attribute key, it is automatically in 2NF once it is in 1NF.

Instrument

Watch it happen.

Step through one operation at a time

Step player01 / 03
01

Start with the 2NF target table

The table violates 2NF: no partial dependency.

Enrollment (1NF, not 2NF)
student_idcourse_idstudent_namecourse_namegrade
1C1AdaDBMSA
1C2AdaOSB
2C1GraceDBMSA

The trade-off

No free correctness.

Gain

Course facts and student facts are stored once.

Cost

Queries that want all three facts must join three relations.

Verdict

Decompose partial dependencies; keep the relationship fact in the junction relation.

Recap

What to keep.

Takeaways

  • +2NF removes partial dependencies on a composite key.
  • +A relation with a single-attribute key is automatically in 2NF if it is in 1NF.
  • +Decompose each partial dependency into its own relation.
  • +The junction table keeps the full-key dependency.
  • +2NF reduces redundancy and update anomalies.

Traps

  • !Applying 2NF to a single-attribute key and expecting changes.
  • !Forgetting that 1NF is a prerequisite.
  • !Losing the relationship between the decomposed tables.

Focus

  • →Identify the composite key.
  • →Test each non-key attribute for full dependency.
  • →Decompose and preserve the junction table.

Check yourself

Before you turn the page.

0 / 2 answered
01

What does 2NF remove?

02

If a relation has a single-attribute primary key and is in 1NF, is it in 2NF?

DB//COSMOS

A field manual for database systems: model the domain, normalize the facts, query the relations, and protect the result.

Edition 2026 · 32 chaptersTopic catalogInterview prep