One-to many relationships in ER diagram

ぐ巨炮叔叔 提交于 2019-11-28 16:54:38

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

I don't think the other answer is fully correct.

I would say that one should use arrows, and one should use a notation that gives a meaningful name to each direction of the relationship. In this case it will be "teaches" in one direction, and "is taught by" in the other. Either use arrows next to the names or put the name near to the entity to which it refers. You could use one line (with two arrow heads) or two lines (with one arrow each).

I would also suggest that cardinality is just one kind of constraint, and the notation should reflect that. For example, the two names for the relationship could be "teaches (many)" and "is taught by (exactly one)". The point is you might have "teaches (one or two)" or "is taught by (exactly two)" and so on.

It is better to be explicit and clear about exactly what your constraints really are.

Both are having exactly opposite cardinality

🔸Simple clean line means many.

🔸Arrow means one.

If we consider both with same cardinality.

then, many to many should be represented by following the second convention as (please assume diamond for relationship set and rectangle for entity set)

   INSTRUCTOR <---- TEACHES -----> COURSE 

which is actually of no meaning.

If we consider both with opposite cardinality.

then, many to many should be represented by following the second convention as (please assume diamond for relationship set and rectangle for entity set)

  INSTRUCTOR ----- TEACHES ------ COURSE

No explicit arrow is always considered many to many. So, it is correct (only if we consider both opposite)

Consider an 'employee' entity set and 'department' entity set, having relationship set as 'manage'. Employee-------------Manage--------------------Department (entity set) (Relationship set) (entity set) One to many relationship means one entity of employee set can be associated with more than one entity of Department entity set but, an entity of Department set can be associated with at most one entity of employee entity set. That means if there is one to many relationship between employee and department entity sets, then each employee can manage more than one department and at the same time each department is managed by at most one employer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!