用关系建模3个实体 [英] Modeling 3 entities with relationships

查看:86
本文介绍了用关系建模3个实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们的环境中有三个实体,即老师学生课程

Say we have three entities in our environment, Teacher, Student and Course.


  • 每个老师(教)一门或更多课程,每门课程由0个或更多老师提供

  • 每个学生都修过一门或更多门课程并且每门课程由0个或更多学生参加

  • 每个老师有0个或更多学生并且每个学生有1个或更多老师

在这种关系中,每个关系都可以从另外两个关系中推论得出,例如,知道T1老师正在教哪个学生,通过老师和课程之间的关系>查看T1老师正在教授哪些课程,然后通过课程与学生之间的关系来了解哪些学生选择了这些课程。这些学生是由T1老师教的。

In this relationships, each relationship could be inferred from the two others, for example to know which Students are being taught by Teacher T1, go through the relationship between Teacher and Course to see what Courses are being taught by the teacher T1, and then go through the relationship between Course and Student to see which Students has taken these Courses. These Students are the ones that are being taught by teacher T1.

因此,我们不需要学生与老师之间的明确关系,因为

So we don't need an explicit relationship between Student and Teacher, because "Conceptually" this relationship exists.

最后问题是:

概念设计是否必须显示所有三个关系?

In Conceptual Design is it necessary to show all the three relationships?

作为附加信息,它在逻辑设计中会如何(设计数据库表和关系),该关系应保留为推断的关系还是应明确定义?

And as an extra information, how would it be in Logical Design (designing database tables and relationships), should the relationship remain as an inferred relationship or should be explicitly defined ?

推荐答案

这里是一个示例,

概念性(使用NORMA)

老师教课程


  • 有些老师可能会教多个Cours e并且对于某门课程,不止一位老师教该课程。

  • 在每位教师教课程中,每位教师,课程组合最多出现一次。

学生参加课程



  • 在每一个学生群体中,每个学生选择的课程组合可能是:

老师辅导课程的学生


  • 对于每位学生和每门课程,最多只能有一位教师辅导该课程的学生。

约束


  • 对于每位老师和每门课程,如果且仅当该老师在该课程上辅导一些学生

  • For each Teacher and Course, that Teacher tutors some Student on that Course if and only if that Teacher teaches that Course.

对于每位学生和每门课程,都有一名教师辅导员

For each Student and Course, some Teacher tutors that Student on that Course if and only if that Student takes that Course.

逻辑

这篇关于用关系建模3个实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆