以下是我要解决的问题:
Entity A : a_id
Entity B : b_id
One A can use Many B's. However, not all Bs are used by all As.
这是我能想到的最好的例子:
One teacher has many students.
Some students are taught by more than one teacher.
什么是关系,所以我可以添加/删除由一位老师教授的学生,但不影响已经教过学生的老师?
答案 0 :(得分:2)
您需要一个将两者联系在一起的StudentTeacher实体。它将有一个a_id列和一个b_id列。
答案 1 :(得分:2)
你需要一个第三个表,称为这两个表之间的映射。创建这个表,所以:
Table Student_Teacher_Mapping
Id (Int)
TeacherId(Int) // foreign key for teacher table
StudentId(Int) // foreign key for student table
我认为这就是你想要的。