There are certain constraints in E-R model. Data in the database must follow the constraints. Constraints act as rules to which the contents of database must conform. There are two types of mapping constraints : (a) Mapping cardinalities, (b) Participation constraints.
1. Mapping Cardinalities (Cardinality Ratios)
It specifies the number of entities of an entity set that are associated with entities of another entity set through a relationship set.
Mapping Cardinalities are helpful in describing binary relationship sets.
Two entity sets X and Y having binary relationship set R must have one of the following mapping cardinality:
- One to One (1 : 1) : An entity in X is associated with at most one entity in Y and an entity in Y is associated with at most one entity in X.
A country has only one president. Any person may be the president of at most one country.
- One to Many (1 : N) : An entity in X is associated with any number of entities in Y. An entity in Y is associated with at most one entity in X.
A manager has many employees under it but an employee works under only one manager.
- Many to One (N : 1) : An entity in X is associated with at most one entity in Y. An entity in Y is associated with any number of entities in X.
A employee can work on single project while any project can be assigned to more than one employee.
- Many to Many (M : N) : An entity in X is associated with any number (zero or more) of entities in Y and vice versa.
A student can have more than one subject and one subject can be given to more than one student.
2. Participation Constraints
The participation constraints are discussed in section 2.9.6.
Source: Gupta Satinder Bal, Mittal Aditya (2017), Introduction to Database Management System, 2nd Edition-University Science Press (2017)