Updated March 15, 2023
Introduction to Mapping Constraints
In a Database Management System, Mapping constraints are implemented to determine the relationships between the entities. This is especially true when the system has a condition where one or more entities can be related to one or more entities in the same Entity-Relationship model. Mapping Constraints are greatly functional in recognizing the relationships between the Entities that involve more than one relationship for any given Entity. Mapping Constraints are also known as the ‘Cardinality Ratio.’ This corresponds to the number of relationship occurrences an entity can be involved in an Entity-Relationship Model. This procedure comes in handy while setting up relationships between the Binary sets. In this topic, we will learn about Mapping Constraints in DBMS.
Types of Mapping Constraints
An Entity-Relationship Model, with two sets of Entities that are considered Binary sets, can have the below four types of Mapping Constraints and their corresponding representations,
- One to one (1:1)
- One to many (1:M)
- Many to one (M:1)
- Many to Many (M M)
1. One to one Cardinality
When one object from an entity is connected with a single object from another entity of the same Entity-Relationship model, then the Mapping Constraint can be termed ‘One to One Cardinality.’ As the name suggests, it can have only one to one relationship. If there appears a need for involving more than one Entity object in the mapping, then the other cardinality types can be used. Here each entity object from the entity set contributes not more than once in the relationship.
The above example (Fig. 01) shows the entity Employee and the entity Salary Account, with the relationship condition as salary. One employee working for any company can have only one Salary account. This applies to all employees, without any exception. Hence this Entity-relationship mapping falls under the one-to-one cardinality type.
2. One to many Cardinality
When one object from an entity is connected with more than one object from the same entity of the same Entity-Relationship model, the Mapping Constraint can be termed ‘One to Many Cardinality.’ As the name suggests, it can have only one to many relationships. If there appears to be a need for involving more than one entity on the left side of the mapping or for only one entity object on the right side, then the other cardinality types can be used. Here one entity object from the left entity set contributes to more than one entity object in the right entity set as the mapping relationship.
The above example (Fig. 02) shows the entity Employee and the entity Sales, with the relationship condition as Job. An employee working for a company can make more than one sale. But not more than one employee can make the same sale. This applies to all employees and sales, without any exception. Hence this Entity-relationship mapping falls under the one-to-many cardinality types.
3. Many to one Cardinality
When many objects from an entity are connected with only one object from the other entity of the same Entity-Relationship model, the Mapping Constraint can be termed ‘Many to one Cardinality.’ As the name suggests, it can have many to-one mapping relationships. If there appears to be a need for involving only one entity on the left side of the mapping or for more than one entity object on the right side, then the other cardinality types can be used. Here many entity objects from the left entity set contribute to only one entity object in the right entity set as the mapping relationship.
The above example (Fig. 03) shows the entity Employee and the entity Sales, with the relationship condition as Job. Many Employees working for a company can report to one Manager. But not one employee can be reporting to more than one Manager. This applies to all employees, managers, and reporting, without any exception. Hence this Entity-relationship mapping falls under the many to one cardinality type.
4. Many to many Cardinality
When many objects from an entity are connected with more than one object from the other entity of the same Entity-Relationship model, the Mapping Constraint can be termed ‘Many to Many Cardinality.’ As the name suggests, it can have many, many mapping relationships. If there appears a need for involving only one entity on the left side of the mapping or for only one entity object on the right side of the mapping, then the other cardinality types can be used. Here more than one entity object from the left entity set contributes to more than one entity object in the right entity set as the mapping relationship.
The above example (Fig. 04) shows the entity Employee and the customer, with the relationship condition as sales. Many Employees working for a company can be making sales to many customers. There is no condition for one employee to make sales with only one customer or for one customer to buy the sale from only one employee. This applies to all employees, sales, and customers, without any exception. Hence this Entity-relationship mapping falls under the many to many cardinality types.
Significance of Mapping Constraints
Mapping Constraints for the Entity-Relationship Model is an important concept for efficiently designing the Database Management System. Below are the few most important reasons for following Mapping Constraints,
- Mapping Cardinality helps describe the relationship between two entity tables in the DBMS by articulating the number of entity instances linked with the instances of the related entities.
- There should be at least one entity object from both the related entity sets to establish mapping constraints between the corresponding entities.
- Mapping Constraints facilitate the DBMS to be well-organized and well-structured, which helps maintain clean data in the tables.
- This also reduces redundancy and no duplication in data, as the mapping does not allow any slippage in data in the tables of the respective entity objects.
Conclusion
Usually, Mapping Constraints in DBMS are derived from the Business policies provided as a requirement in the project. These are used to decide the cardinality types and the connectivity between the entity objects. This is most commonly used in relational databases and multidimensional database management systems. Therefore, it is necessary for the Database Architecture process while crafting the Database Management Systems.
Recommended Articles
This is a guide to Mapping Constraints in DBMS. Here we discuss the Types of Mapping Constraints along with their Significance. You may also have a look at the following articles to learn more –