Composite Key chapter corrected #61
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why the composite key example violates 2NF
The composite key example in the chapter uses a table where the primary key is made up of two columns: student_number and school_id. In this structure, if there is a non-prime column (a column not part of the primary key), such as name, and it depends only on part of the composite key (for example, just student_number), this is called a partial dependency. 2NF requires that all non-prime columns depend on the whole primary key, not just a part of it.
In the example, if name depends only on student_number (and not on both student_number and school_id), then the table is not in 2NF. This is because knowing just the student_number gives you the name, regardless of the school_id. This violates the rule of 2NF, which says there should be no partial dependency of any column on a subset of a candidate key.