例如我在用户表中有1个表,其中包括教师和学生,而1个教师可以在自己的表中添加该学生。如何设计数据库?哪个更好?
这是第一张用户表,我想将FK添加到用户表中
id | email | password | status | teacher_id (which refer to user_id)
1 | test@hot| 211231 | teacher| null
2 | t2@hot | 12321 | student| 1
3 | t3@hot | 121312 | student| 4
4 | t4@hot | 313 | teacher| null
2nd我想将sperate表分成2个表
User
id | email | password | status |
1 | test@hot| 211231 | teacher|
2 | t2@hot | 12321 | student|
3 | t3@hot | 121312 | student|
4 | t4@hot | 313 | teacher|
Parents
id|teacher_id|student_id
1 | 1 | 2
2 | 4 | 3
注意:我希望1个学生只能有1个老师