Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One-to many relationships in ER diagram

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.

enter image description here

enter image description here

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.

like image 263
yrazlik Avatar asked Apr 09 '13 08:04

yrazlik


People also ask

How do you show one-to-many relationship in ERD?

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.

What is a one-to-many relationship example?

Some common examples of one-to-many relationships are: A car maker makes many different models, but a particular car model is built only by a single car maker. One customer may make several purchases, but each purchase is made by a single customer.

What is the relationship of one-to-many?

In a one-to-many relationship, one record in a table can be associated with one or more records in another table. For example, each customer can have many sales orders.

Which symbol on an ERD represents a one-to-many relationship?

Many-to-Many relation: A one-to-many relationship is represented by adding 'M' near the entity at left hand side of relation and 'N' is written near the entity at right side. Other type of notation will have three arrow kinds of lines at both sides of relation as shown below.


2 Answers

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.

ER Digram

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

like image 175
Dulantha Avatar answered Oct 04 '22 06:10

Dulantha


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.

like image 26
debater Avatar answered Oct 04 '22 05:10

debater