ER图中的一对多关系 [英] One-to many relationships in ER diagram

查看:2884
本文介绍了ER图中的一对多关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在ER图中显示以下内容:

 有教师和课程,只有一个教练
,而教练可以给很多课程。





我的问题是,两个图之间有什么区别,换句话说,是什么线我们变成一个箭头,只是箭头的方向?



此外,如果我们考虑映射基数;是1到多还是多到1?如果我们考虑课程,那么它是多对一,但如果我们认为在教师,那么它是一对多。我们如何决定这一点?
谢谢。

解决方案

在ER图中,当表示关系时,不使用箭头。一些教练在他们想决定基数时,使用这个箭头,但这只是为了获得基数(1:1,1:M和N:M)







决定关系的基数是一个实际情况,没有硬和通过规则来获得它。你需要做的是从关系的一侧开始,并采取一个元组(实例),并看到有多少元组从其他实体参与的关系。然后做反之亦然。然后你知道元组的参与数量)从每个实体到关系。当你决定基数(即教师组,课程集和教学关系类型集)时,考虑数学中的集合理论和函数,那么这是很容易的,但如果你不是从数学背景只是想到实际情况。 / p>

例如



a)对于1位教师, M)课程



b)对于1课程,只有1个教师



1在a)和b)但在课程中有M和1在a)和b)有教师:课程基数是1:M


I am trying to show the following in the ER diagram:

There are instructors and courses, a course is taught by only one instructor
whereas an instructor can give many courses.

My question is, is there any difference between two diagrams, in other words, does it matter which line we turn into an arrow, or what only matters is only the direction of the arrow?

Also, if we think about the mapping cardinalities; is it 1 to many or many to 1? If we think in terms of courses, then it is many to one but if we think in terms of instructors, then it is one to many. How do we decide this? Thank you.

解决方案

In ER diagrams when the relationship is denoted the arrows are not used. Some instructors use this arrow when they want to decide the cardinalities but that is just to get the cardinality (1:1, 1:M and N:M)

I have attached the ER diagram for this in Chen notation and also using Crow Notation you can use either of them.

Deciding the cardinality for a relationship is a practical scenario there is no hard and pass rule to obtain it. What you need to do is start from one side of the relationship and take one tuple (instance) and see how many tuples from the other entity participate for the relationship. Then do the vise versa. Then you know the participation number of tuples) from each entity to the relationship. Think about set theory and functions in mathematics when you decide the cardinality (ie Set of instructors, Set of Courses and set of Teaches relationship type) then this is so easy but if you are not from a mathematic background just think of practical scenario.

For Example

a) For 1 instructor he or she can teach Many (M) courses

b) For 1 Course there is only 1 instructor

so in instructor side there is always 1 in a) and b) but in Courses there is M and 1 in a) and b) there for Instructor:Course cardinality is 1:M

这篇关于ER图中的一对多关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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