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.
编辑:关系必须是1比1。学生只存在于一所学校。
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;
1 个解决方案
#1
3
Option1 one makes sense if a student can only attend one school. Option2 is necessary if a student can attend multiple schools.
选项1如果一个学生只能上一所学校,那么这个选项是有意义的。如果一个学生可以上多所学校,那么第二种选择是必要的。
#1
3
Option1 one makes sense if a student can only attend one school. Option2 is necessary if a student can attend multiple schools.
选项1如果一个学生只能上一所学校,那么这个选项是有意义的。如果一个学生可以上多所学校,那么第二种选择是必要的。