Sub topic 2
Cardinality Ratios and Participation Constraints
Assume you know what an entity, relationship, table, row, and column are. This chapter uses entity-relationship (ER) notation to describe how many entity instances may take part in a relationship.
Cardinality Ratios
A cardinality ratio states the maximum number of instances that can participate in a relationship. For a relationship between Student and Course, common ratios are:
| Ratio | Meaning | Example |
|---|---|---|
| 1:1 | Each instance on either side relates to at most one instance on the other side | Person has one passport |
| 1:N | One instance on one side relates to many on the other side | Department employs many employees |
| M:N | Many instances on both sides may relate to many instances | Students enroll in courses |
In a 1:N relationship, the side marked N is the many side. For example, one department can employ many employees, while each employee belongs to at most one department.
An M:N relationship usually represents a set of pairings. A student may enroll in many courses, and a course may have many students. Each enrollment is one pairing between one student and one course.
Participation Constraints
A participation constraint states the minimum number of relationship instances required for each entity instance. It answers whether participation is mandatory.
- Total participation means every entity instance must participate at least once.
- Partial participation means an entity instance may participate zero times.
For example, suppose every employee must work for a department. Employee has total participation in works_for. A department may exist before it has employees, so Department has partial participation.
The min-max notation makes both limits explicit. (0,1) means zero or one related instance. (1,1) means exactly one. (0,N) means zero or many. (1,N) means one or many.
| Entity role | Min-max constraint | Interpretation |
|---|---|---|
| Employee in `works_for` | (1,1) | Every employee works for exactly one department |
| Department in `employs` | (0,N) | A department may employ no employees or many |
Cardinality and participation are different. A relationship can have a maximum of one but still be optional, as (0,1) shows. It can also have a maximum of many while requiring at least one, as (1,N) shows.
Applying the Constraints
For each relationship, ask:
- What is the maximum number of related instances in each direction?
- What is the minimum number?
- Is participation mandatory or optional?
- Does the wording apply to every entity, or only to some entity instances?
Words such as “must,” “exactly one,” and “at least one” usually indicate total participation. Words such as “may,” “can,” and “zero or more” indicate partial participation.
Exercise
A course may have zero or many students, and every student must enroll in one or more courses. What are the min-max constraints?
Show answer
Course is (0,N), and Student is (1,N).