1

This is my current database design, for the moment just look the student, teacher and classes tables.

enter image description here

I'm trying to convert some tables into news using TPH Inheritance. For example.

Create a new table called Person where contains:

  • Id,
  • FullName,
  • EnrollmentDate (for student),
  • Email (for student),
  • HireDate (for teacher)

But is there remaining one field called ClassId, where it's contained in Student table. At this momment I don't know if should I create a join table to store the ClassId and PersonId, or just put the ClassId into the Person table. That's my big doubt.

Where do I have to put the ClassId field?

I have to mention that each student can only be in one class, not many. Teachers can have many classes as they want.

4

1 回答 1

0

我认为您没有正确建模域:

首先你必须有学生,不管他们有没有班级,
在当前的模型中,学生似乎是一个弱实体并且依赖于班级。

课程也独立于学期课程,学期课程可能会在今年发生,明年不会发生。

但是,如果您想使用 TPH 策略对数据库进行建模,此链接可能会对您有所帮助。

您将有一个 Person 表,然后是具有对 Person 的引用的 Teacher 表,以及也具有对 Person 表的引用的 Student。
最后,学生表通过联合表引用学期课程。

于 2013-01-12T19:58:41.593 回答