Volume 01 · Workbench
Operate the model.
Three instruments for the parts of a DBMS that are easiest to memorize and hardest to see: cardinality, algebra, and decomposition. Change an input and watch the schema answer.
Instrument 01 / 03
Cardinality mapper
The relationship decides the foreign key. Find the many side first, then look for the junction.
Student— enrolls —CourseM : N
Many students take many courses. Create Enroll(student_id, course_id) with foreign keys to both sides. The composite key prevents duplicate enrollments.
Student
| id | name |
|---|---|
| 1 | Ada |
| 2 | Grace |
Enroll
| student_id (FK) | course_id (FK) |
|---|---|
| 1 | C1 |
| 1 | C2 |
| 2 | C1 |
Course
| id | title |
|---|---|
| C1 | DBMS |
| C2 | OS |
Relational mapping
Create a junction table
ERDtables
Rule: a 1:N relationship becomes a foreign key on the many side; an M:N relationship becomes a junction table.