Second Normal Form (2NF) and Partial Dependencies
Fast recall
Quick revision
Core answer
Understanding non-prime attributes, candidate keys, and partial dependency on a proper subset of a candidate key
Checking only the selected primary key and overlooking another composite candidate key
Identify the determinant and dependent attribute explicitly, then verify every candidate key
Interview-ready guide
Interview answer
A relation is in 2NF when it is in 1NF and every non-prime attribute depends on every whole candidate key, not a proper subset. In order_items(order_id, product_id), quantity may depend on both values, while product name depends only on product_id. Move product name to Product and keep product_id as a reference. If every candidate key is one column, a 2NF violation is impossible because there is no proper subset of a key to test.
Second Normal Form (2NF) and Partial Dependencies
Direct Answer
A relation is in Second Normal Form when it is in 1NF and every non-prime attribute is fully functionally dependent on every candidate key. A partial dependency exists when a non-prime attribute depends on a proper subset of a composite candidate key. Therefore a relation whose candidate keys are all single-column cannot have a 2NF violation; checking only the chosen primary key can miss another candidate key.
Common Mistakes & Pitfalls
- Checking only the primary key: A different composite candidate key can expose a partial dependency.
- Confusing 2NF with 3NF: 2NF concerns a non-prime attribute depending on part of a candidate key; 3NF tests all relevant functional dependencies.
- Missing the repeated determinant: In
(order_id, product_id)rows, product details depend onproduct_idalone.
Check your understanding
Answer these without looking back at the article.
- Can a table with a single-column primary key violate 2NF?
- What kind of anomaly does a partial dependency cause?
- How does splitting tables to fix 2NF affect queries?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.