展开无限ERD
我有一个学校作业的 erd,其中包含多对多关系,据我所知,这是不可扩展的。我有一堂课可以由许多老师授课(就像许多老师在同一个房间同时教同一个人),并且指定一名老师作为班主任,所以据我所知,一个班级可以由多名教师授课,并且多名教师可以(同时)教授同一班级。有谁知道我如何扩展这个?
我尝试过制作一周的实体,例如小组。所以一堂课由一组教,一组可以教很多课,但我仍然遇到一个组可以有很多老师并且很多老师可以在一个组中的问题。 从每个角度来看,我最终都会在老师与班级或弱实体之间建立多对多的关系,任何帮助将不胜感激。 谢谢
i have an erd for a school assignment that contains a many to many relationship that as far as i can tell is un-expandable. I have a class that can be taught by many teachers (as in many teachers in the same room at the same time teaching the same people) and one teacher is assigned as the head teacher, so as far as i can see, one class can be taught by many teachers and many teachers can teach the same class (at the same time). Has anyone got any idea how i could expand this?
I have tried making a week entity eg group. so one class is taugt by one group and one group can teach many classes but i still end up with the issue of one group can have many teachers and many teachers can be in a group.
Every way i look at i end up with a many to many relationship between teacher and either class or the weak entity, any help would be greatly appreciated.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
建模 m:n 关系的常用(也是最好)方法是创建中间关联。
在这种情况下,班级和关联之间将具有 1:m 关系(因为每个班级可以与许多教师关联),而教师和关联之间也会有 1:m 关系(因为每个教师可以与许多班级关联)。
在创建表时,关联本身就成为一个表,具有 Class 和 Teacher 的外键,从而将它们链接在一起。
The usual (and best) approach to modeling m:n relationships is to create an intermediate association.
In this case you would have a 1:m relationship between Class and the association (since each class can be associated with many teachers) and also a 1:m relationship between Teacher and the associtaion (since each teacher can be associated many classes).
When it comes to creating tables, the association becomes a table in its own right, with foreign keys to both Class and Teacher, thus linking them together.