Open In App

Cardinality in DBMS

Last Updated : 16 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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-one 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.

Similar Reads

Equal Sets: Definition, Cardinality, and Venn Diagram
Equal Set is the relation between two sets that tells us about the equality of two sets i.e., all the elements of both sets are the same and both sets have the same number of elements as well. As we know, a set is a well-defined collection of objects where no two objects can be the same, and sets can be empty, singleton, finite, or infinite based o
9 min read
Domain constraints in DBMS
In DBMS, constraints are the set of rules that ensures that when an authorized user modifies the database they do not disturb the data consistency and the constraints are specified within the DDL commands like "alter" and "create" command. There are several types of constraints available in DBMS and they are: Domain constraintsEntity Integrity cons
4 min read
Cursors in DBMS - Definition, Types, Attributes, Uses
Database Management System(DBMS) supports Data Manipulation Language statements like Insert, Update and Delete queries. Each database syntactically differs but the functionality remains the same in the mentioned operations. In this article, let us see about performing insert, update and delete queries using the cursor. Cursors Whenever DML statemen
5 min read
Degree of Relations in DBMS
We are living in a world where every entity has relationships with one other whether a living or non-living being. For example, you are a single entity but you share different relations with your family and friends. Even within a family, you are the son of your father at the same time you are also a sibling of your brother. Similarly, the relations
4 min read
DBMS