这种非常简单的关系有意义吗?
所以我只是想知道这对于外键关系意味着什么。我有两张桌子。课程和学校。一所学校可以开设多门课程。那么下面的关系有意义吗?
So I am just wondering what it means for a foreign key relationship. I have two tables. Courses and Schools. One school can have many courses. So does the following relationship make sense?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关系看起来很公平。这些课程与学校相关。如果您想要在多所学校教授一门课程,这可能会引起问题。在这种情况下,您应该在它们之间添加一个“链接”表。该表将包含课程和学校 ID(告诉哪些项目相互链接)。
在您的示例中,我能想到的唯一一件负面的事情是表的命名,所有表都以 proj_ 为前缀,而列则预先填充了表的名称(对于外键,也是链接表的名称)。链接 course_schoolId 链接到表 proj_school,这可能会导致较大数据模型中的混乱。
Relation looks fair. The courses are linked to a school. It might cause issues if you want to have a course that is teached at multiple schools. In that case you should add a "link" table between them. That table would contain couse and school id's (telling what items are linked to eachother).
Only one negative thing I can think about in your example is the naming of you tables, all tables are prefixed with proj_ while the columns are prefilled with the name of the table (and for Foreign keys the name of the linked table too). The link course_schoolId links to the table proj_school, this might cause confusion in larger datamodels.