Verified Jobs Live
Database Medium Level ~3 min read

How would you model a many-to-many relationship between students and courses?

Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Model Answer & Deep-Dive Explanation

Create students and courses tables plus an enrollment table containing foreign keys to both. Add a primary key or unique constraint on the student-course pair if only one enrollment is permitted. Attributes such as enrollment date, grade, or status belong to the relationship record. If repeat enrollment is allowed, include a term or enrollment identifier in the model instead of forcing false uniqueness. Define deletion and history rules explicitly. A comma-separated list of course IDs in the student row makes integrity checks, queries, and updates unnecessarily difficult.