Reputation: 61
Using this simplified example; what approach do you think is better and why?
Edit: The relation must be 1 to 1. A student only exists in one school.
Option1
**Table Schools:**
id int primary key;
name string;
**Table students:**
id int primary key;
name string;
idSchool int;
Option2
**Table Schools:**
id int primary key;
name string;
**Table Students:**
id int primary key;
name string;
**Table SchoolsStudents**
idSchool int;
idStudent int;
idSchool, idStudent as primary key;
Upvotes: 1
Views: 205
Reputation: 39278
Option1 one makes sense if a student can only attend one school. Option2 is necessary if a student can attend multiple schools.
Upvotes: 3