我对数据库关系有点困惑。我正在使用 laravel 并且需要良好的关系实践。我有四张桌子老师,班级,部分和科目。所以老师在多个部分教授多个科目的多个班级。例如
teacher1 teaches class9 of subject English in section A and B
teacher1 teaches class9 of subject Math in section A
teacher1 teaches class9 of subject Chemistry in section A and b
teacher2 teaches class9 of subject English in section A and B
teacher2 teaches class9 of subject Math in section A
teacher2 teaches class9 of subject Chemistry in section A and b
teacher2 teaches class10 of subject English in section A and B
teacher2 teaches class10 of subject Math in section A
teacher2 teaches class10 of subject chemistry in section A and c
所以这是我的场景,我有四个没有关系的表,比如有教师记录的教师,有第 10、第 9 等记录的班级,有英语、数学等记录的科目以及 A、B、C 等部分。那么什么是在这些表之间创建关系的最佳实践以及如何在 laravel 中使用 eloquent 关系。
这是我的 ER 图。如果是,它是正确的设计,那么如何在 laravel 中创建雄辩的关系?