Quick revision
The short answer
The table is in 1NF but violates 2NF, because student_name depends only on student_id and course_title and instructor depend only on course_id, which are partial dependencies on part of the composite key. We decompose it into students(student_id, student_name), courses(course_id, course_title, instructor) and enrollments(student_id, course_id, grade). The split is lossless, since joining on the keys gives back the original rows.
What to remember
In this answer, we listed what each column of enrollments depends on and found that student_name, course_title and instructor depend on only part of the composite key, which breaks 2NF and causes update, insertion and deletion anomalies. We decomposed the table into students, courses and enrollments, saw how a dependency such as instructor -> office would be a transitive dependency to remove for 3NF, and confirmed the split is lossless because each join is on the key of one side.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The table is in 1NF but violates 2NF, because student_name depends only on student_id and course_title and instructor depend only on course_id, which are partial dependencies on part of the composite key. We decompose it into students(student_id, student_name), courses(course_id, course_title, instructor) and enrollments(student_id, course_id, grade). The split is lossless, since joining on the keys gives back the original rows.
Why this question is asked
Normalization questions are often asked with a small table like this one because it lets the interviewer see whether we can reason from dependencies rather than recite definitions. The same reasoning applies whenever we review a real schema and notice that the same customer name appears in a thousand rows. In this answer, we will recap functional dependencies and the first three normal forms, find the dependencies hidden in the enrollments table, see the anomalies they cause, decompose the table, and check that the decomposition loses nothing.
1A Quick Recap of Functional Dependencies and Normal Forms
A functional dependency, written A -> B, means that whenever two rows have the same value of A, they must have the same value of B. In plain words, A determines B. student_id -> student_name says a student id always comes with the same name.
First normal form (1NF) asks that every column holds one atomic value and rows are identified by a key. Second normal form (2NF) adds that no non-key column depends on only part of a composite key; such a dependency is called a partial dependency. Third normal form (3NF) adds that no non-key column depends on another non-key column, which is called a transitive dependency. Each step removes a kind of duplication.
2Finding the Dependencies in enrollments
The key is (student_id, course_id): one row per student per course. Let us go through each non-key column and ask what it really depends on.
| Column | Determined by | Problem |
|---|---|---|
| grade | (student_id, course_id) | None, depends on the whole key |
| student_name | student_id only | Partial dependency, breaks 2NF |
| course_title | course_id only | Partial dependency, breaks 2NF |
| instructor | course_id only | Partial dependency, breaks 2NF |
Only grade belongs here: it is a fact about one student in one course. The other three are facts about a student alone or a course alone, so they are repeated in every enrollment row. The table is in 1NF (every value is atomic and there is a key) but not in 2NF. We assume here that each course has one instructor; if a course could have several, instructor would not depend on course_id alone and the design would need its own table.
3The Anomalies This Causes
Repetition is not just wasted space. It creates three kinds of anomaly, situations where a normal operation gives a wrong or impossible result.
Notice that all three come from the same cause: a fact about a course or a student is stored as part of a fact about an enrollment.
4Decomposing to 2NF and 3NF
We move each fact to a table whose key is exactly what determines it.
Renaming a course now changes one row, and every enrollment sees the new title through the join. A course can exist before anyone enrolls, and deleting an enrollment never deletes a student.
Are these tables also in 3NF? Yes, as long as no non-key column determines another. But imagine the courses table also had instructor_office. The office depends on the instructor, not on the course, so course_id -> instructor -> instructor_office is a transitive dependency. To reach 3NF we would move it out to instructors(instructor, office) and keep only the instructor reference in courses.
5Checking That the Decomposition Is Lossless
A decomposition is lossless when joining the pieces gives back exactly the original rows, with nothing missing and nothing invented. The rule is that the shared columns of each join must be a key of one side. Here enrollments joins students on student_id, the key of students, and courses on course_id, the key of courses.
Because each join matches exactly one student and one course for every enrollment, no row is duplicated and none is lost. The original table can always be rebuilt as a view if old reports depend on its shape.
6Follow-up questions
What is an insertion anomaly in the original table?
It is when we cannot record a fact without inventing another one. In the original table we cannot store a new course, its title and instructor, until some student enrolls, because student_id is part of the primary key and cannot be null. The same goes for a new student who has not enrolled in anything yet. After the decomposition, courses and students have their own tables and can be inserted independently.
Is the original table in 1NF?
Yes. Each column holds a single value and the rows are identified by the composite key. 1NF problems look different, such as a column holding a comma-separated list of courses. The issues here start at 2NF.
Does a table with a single-column primary key ever violate 2NF?
No. A partial dependency needs a composite key, because it means depending on part of the key. A table with a single-column key is automatically in 2NF if it is in 1NF, although it can still violate 3NF through transitive dependencies.
7Conclusion
In this answer, we listed what each column of enrollments depends on and found that student_name, course_title and instructor depend on only part of the composite key, which breaks 2NF and causes update, insertion and deletion anomalies. We decomposed the table into students, courses and enrollments, saw how a dependency such as instructor -> office would be a transitive dependency to remove for 3NF, and confirmed the split is lossless because each join is on the key of one side.
Open with
The key is student_id plus course_id, so I would go column by column and ask what each one really depends on. Grade depends on the whole key, which is fine.
Then, if they want more
But student_name depends only on student_id, and course_title and instructor depend only on course_id. Those are partial dependencies on part of a composite key, so the table is in first normal form but violates second normal form.
The practical effect is anomalies: renaming a course means updating every enrollment row and missing some leaves two titles; I cannot add a course before someone enrolls, because student_id is part of the key; and deleting a student's last enrollment loses their name.
I would decompose it into students with student_id and name, courses with course_id, title and instructor, and enrollments with student_id, course_id and grade, with foreign keys to the other two. That is in 2NF and also 3NF, as long as nothing else hides in courses.
If, say, courses also had the instructor's office, that would be a transitive dependency through instructor, and I would move it to an instructors table. The decomposition is lossless because each join uses the key of one side, so joining the three tables gives back exactly the original rows, and I can keep a view for old reports.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A table enrollments(student_id, course_id, student_name, course_title, instructor...": https://scrivio-interview-library.netlify.app/databases/data-modeling/b625a5f137/