Database.Beginner.2NF.Details

What is a Partial Dependency?

A partial dependency happens when a column (like student_name) depends on part of a composite key (like student_id), not the whole key (student_id, course).


Let’s See the Table Again

Imagine this table:

student_idcoursestudent_name
1MathAlice
1HistoryAlice
2MathBob

Suppose:

  • Primary Key = (student_id, course) → both columns together uniquely identify a row.
  • This means both student_id and course are needed to tell one row apart from another.

What depends on what?

  • student_name — it depends only on student_id.
    • Wherever student_id = 1, the name is always “Alice”, no matter what course.
    • It has nothing to do with which course the student takes.

But:

  • In a properly normalized table, all non-key columns should depend on the whole key — not just a part of it.

Why is this bad?

  • Redundancy: “Alice” is repeated for every course Alice takes.
  • Update problem: If Alice changes her name, you must update it in every row where student_id = 1.
  • Data inconsistency: You could accidentally have “Alice” for Math and “Alise” for History — two different names for the same student!

Real-world Analogy

Think of it like this:

  • Suppose you have a rental system where the key is (PersonID, CarID) because one person can rent multiple cars.
  • But you store the person’s name with each rental.
  • The name depends only on the person — not on which car they rent.

You shouldn’t repeat the name for each rental; you should store it once in a Person table!

Correct Fix — Split the Table

Students (student_id → student_name):

student_idstudent_name
1Alice
2Bob

Enrollments (student_id + course):

student_idcourse
1Math
1History
2Math

Now:

  • student_name depends only on student_id (good — and we don’t repeat it).
  • course depends on both student_id and course (good — this pair is unique).

Key Point

In 2NF, every non-key column must depend on the whole composite key — not just part of it.

If you can say:

“This column only needs student_id to be known, not the full (student_id, course)” — then you have a partial dependency, and you are NOT in 2NF.

This entry was posted in Без рубрики. Bookmark the permalink.