Relationships in the E-R diagram play a very vital role as they are the ones with the help of which one can convert any E-R diagram into database tables. The concept of relationships in the E-R diagram involves a degree of relationship, mapping cardinalities, and participation constraints. As we have discussed so far that an E-R diagram is a collection of basic real-world objects called entities and relationship among entities. The basic reason for using E-R diagrams is that they are translatable into relational tables which allows you to build databases quickly.
It means number of entities sets associated (participated) in the relationship set. Most of the relationship in the E-R diagram are binary. Occasionally, however, relationship sets involve more than two entity sets. The number of entities set participating in a relationship set are classified as follows:
As the name says the relationship set involves only one type of entity. For example, Employee is an entity set. Figure below shows a method to represent an entity set.
One Employee showing relationship with another Employee. The figure below shows another method to represent the E-R diagram containing single entity set.
It is one of the most common types of relationship which requires two entities in a relationship set. For example, Teacher and Student are two entity sets as shown in the figure below.
Three entities sets in a relationship are ternary relationships. For example, the relationship among Teacher, Student, and Course.
The type of relationships which involve four different entity sets are quaternary relationships. The figure below shows the quaternary relationship.
There are situations where more than four entities sets are required to represent the relationship sets. Such type of relationship sets are N-ary and can be represented as.
It is the number of occurrences in one entity which are associated to the number of occurrences in another. In other words, it is used to describe relationship set of any degree but is most useful in binary relationship. Different types of cardinalities present in an E-R diagram are:
By looking at the E-R diagram, one can determine which type of cardinality ratio is used in the relationship.
In one-to-one , one occurrence of entity set relates to at most one occurrence of another and vice versa. Note that in one-to-one, there can be possibility that entities do not participate in the relationship. One-to One relationship rarely exists in practice but it does. For example, an Indian Citizen possesses only one Adhar Card and one Adhar Card number is associated with only one citizen.
One can use different notations for representing relationships. However, rather writing the number of occurrences over an edge of a relationship, arrows are used to represent the type of relationship. For example,
Is it possible that there no relationship between entities in one-to-one relations? Yes, it is possible that entities do not have any relationship between them.
In one-to-many relationship, one occurrence in an entity relates to at most many occurrences in another entity but the reverse is not true. The other entity can relate to at most one entity of the first. For instance, an Indian Citizen can have more than one Mobile Number. One Mobile number cannot be related to more than one citizen
One can use different notations for representing relationships. The edge without any arrow represents many occurrences.
We can quote the above-given example for many-to-one relationship as well. Many mobile numbers can be related to one citizen.
In many-to-many relationship where many occurrences in one entity relates to many occurrences in another entity. For instance, Teacher Student relationship where many Teachers teaches many Students.
Participation constraints specify whether the existence of an entity depends on its being related to another entity. These constraints specify the minimum and maximum number of relationship instance that each entity constraint participates in. It defines whether an entity participates in a relationship and how many times it can participate.
Participation constraints are of two types: