Skip to content
Related Articles

Related Articles

Cardinality in DBMS

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Medium
  • Last Updated : 10 Feb, 2022

In database management, cardinality plays an important role. Here cardinality represents the number of times an entity of an entity set participates in a relationship set. Or we can say that the cardinality of a relationship is the number of tuples (rows) in a relationship. Types of cardinality in between tables are:

  • one-to-one
  • one-to-many
  • many-to-one
  • many-to-many

Mapping Cardinalities

In a database, the mapping cardinality or cardinality ratio means to denote the number of entities to which another entity can be linked through a certain relation set. Mapping cardinality is most useful in describing binary relation sets, although they can contribute to the description of relation sets containing more than two entity sets. Here, we will focus only on binary relation sets means we will find the relation between entity sets A and B for the set R. So we can map any one of following the cardinality:

1. One-to-one: In this type of cardinality mapping, an entity in A is connected to at most one entity in B. Or we can say that a unit or item in B is connected to at most one unit or item in A.

Figure 1

Example:

In a particular hospital, the surgeon department has one head of department. They both serve one-to-one relationships.

2. One-to-many: In this type of cardinality mapping, an entity in A is associated with any number of entities in B. Or we can say that one unit or item in B can be connected to at most one unit or item in A.

Figure 2

Example:

In a particular hospital, the surgeon department has multiple doctors. They serve one-to-many relationships.

3. Many-to-one: In this type of cardinality mapping, an entity in A is connected to at most one entity in B. Or we can say a unit or item in B can be associated with any number (zero or more) of entities or items in A.

Figure 3

Example:

In a particular hospital, multiple surgeries are done by a single surgeon. Such a type of relationship is known as a many-to-many relationship.

4. Many-to-many:  In this type of cardinality mapping, an entity in A is associated with any number of entities in B, and an entity in B is associated with any number of entities in A.

Example:

In a particular company, multiple people work on multiple projects. They serve many-to-many relationships.

The appropriate mapping cardinality for a particular relation set obviously depends on the real-world situation in which the relation set is modeled.

  • If we have cardinality one-to-many or many to one then, we can mix relational tables with many involved tables.
  • If the cardinality is many-to-many we cant mix any two tables.
  • If we have a one-to-one relation and we have total participation of one entity then we can mix that entity with a relation table and if we have total participation of both entities then we can make one table by mixing two entities and their relation.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!