Concept Flow - Many-to-many relationships
Entity A
Join Table / Link Table
Connects multiple A to multiple B
Two entities connect through a join table that links many items from one to many items of the other.
Entity A: Students Entity B: Courses Join Table: Enrollments Student 1 enrolls in Course A and B Student 2 enrolls in Course B
| Step | Action | Entity A (Student) | Entity B (Course) | Join Table (Enrollments) |
|---|---|---|---|---|
| 1 | Add Student 1 | Student 1 | - | - |
| 2 | Add Course A | Student 1 | Course A | - |
| 3 | Add Course B | Student 1 | Course A, Course B | - |
| 4 | Enroll Student 1 in Course A | Student 1 | Course A, Course B | (Student 1, Course A) |
| 5 | Enroll Student 1 in Course B | Student 1 | Course A, Course B | (Student 1, Course A), (Student 1, Course B) |
| 6 | Add Student 2 | Student 1, Student 2 | Course A, Course B | (Student 1, Course A), (Student 1, Course B) |
| 7 | Enroll Student 2 in Course B | Student 1, Student 2 | Course A, Course B | (Student 1, Course A), (Student 1, Course B), (Student 2, Course B) |
| 8 | End | 2 students | 2 courses | 3 enrollments linking students and courses |
| Variable | Start | After 1 | After 2 | After 3 | After 4 | Final |
|---|---|---|---|---|---|---|
| Students | [] | [Student 1] | [Student 1] | [Student 1] | [Student 1, Student 2] | [Student 1, Student 2] |
| Courses | [] | [] | [Course A] | [Course A, Course B] | [Course A, Course B] | [Course A, Course B] |
| Enrollments | [] | [] | [] | [(Student 1, Course A)] | [(Student 1, Course A), (Student 1, Course B)] | [(Student 1, Course A), (Student 1, Course B), (Student 2, Course B)] |
Many-to-many relationships connect multiple items from one group to multiple items in another. A join table stores pairs linking entities. Each pair represents one connection. This allows flexible, multiple links both ways. Common in databases for students-courses, tags-posts, etc.