Relationships in the E-R Diagram

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.

Degree of a Relationship

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:

  1. Unary
  2. Binary
  3. Ternary
  4. Quaternary
  5. N-ary
Unary

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.

Unary Relationship
Unary Relationship

One Employee showing relationship with another Employee. The figure below shows another method to represent the E-R diagram containing single entity set.

Different Representation of Unary Relationship
Unary Relationship
Binary

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.

Binary Relationship
Binary Relationship
Ternary

Three entities sets in a relationship are ternary relationships. For example, the relationship among Teacher, Student, and Course.

Ternary Relationship
Ternary Relationship
Quaternary

The type of relationships which involve four different entity sets are quaternary relationships. The figure below shows the quaternary relationship.

Quaternary Relationship
Quaternary Relationship
N-ary

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.

N-ary Relationship
N-ary Relationship

Mapping Cardinalities/ Cardinality Ratio

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:

  1. One-to One (1:1)
  2. One-to-Many (1:N)
  3. Many-to-One (N:1)
  4. Many-to-Many (M:N)

By looking at the E-R diagram, one can determine which type of cardinality ratio is used in the relationship.

One-to One (1:1)

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-to-One Relationship

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,

One-to-One Relationship

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.

One-to-Many (1:N)

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-to-Many Relationship

One can use different notations for representing relationships. The edge without any arrow represents many occurrences.

One-to-Many Relationship

Many-to-One (N:1)

We can quote the above-given example for many-to-one relationship as well. Many mobile numbers can be related to one citizen.

Many-to-Many (M:N)

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.

Many-to-Many Relationship

Participation Constraints

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:

  1. Maximum Cardinality: It defines the maximum number of times an entity occurrence participating in a relationship.
  2. Minimum Cardinality: It defines the minimum number of times an entity occurrence participating in a relationship.

Other Useful Links

Entity Relationship Model

Leave a Reply

Your email address will not be published. Required fields are marked *