Cardinality in DBMS
In database management, 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. It is a fundamental concept that helps define how data in different tables connect and how many unique entries exist in a particular column. In this article, we will discuss about cardinality in detail along with all its types.
What is Mapping Cardinality?
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 it can contribute to the description of relation sets containing more than two entity sets.
Types of cardinality in between tables are:
- One-to-One
- One-to-Many
- Many-to-One
- Many-to-Many
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.

Example:
In a particular hospital, the surgeon department has one head of department. They both serve one-to-one relationships.
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.

Example:
In a particular hospital, the surgeon department has multiple doctors. They serve one-to-many relationships.
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.

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.
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.
Conclusion
In conclusion, cardinality in DBMS plays a crucial role in understanding the relationships between tables and the uniqueness of data within columns. By measuring the cardinality, database designers can optimize the performance and integrity of a system, ensuring efficient storage, retrieval, and management of data.