0

这是我要解决的问题:

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.

什么是关系,所以我可以添加/删除由一位老师教的学生,但不影响已经教过学生的老师?

4

2 回答 2

2

您需要一个 StudentTeacher 实体,它将两者联系在一起。它将有一个 a_id 列和一个 b_id 列。

于 2012-06-10T02:36:10.917 回答
2

您需要第三个表,称为这两个表之间的映射。创建此表,以便:

Table Student_Teacher_Mapping

   Id (Int)
   TeacherId(Int)  // foreign key for teacher table  
   StudentId(Int)  // foreign key for student table

我想这就是你想要的。

于 2012-06-10T02:42:39.480 回答