1. Cardinality (Mapping Constraints)
Cardinality defines how many instances of one entity can be associated with instances of another entity in a relationship. It reflects quantitative constraints.
Â
Common Cardinalities:
One-to-One (1:1)
One entity instance in A is related to at most one in B, and vice versa.
Example: Each Person
has one Passport
.
Â
One-to-Many (1:N)
One entity in A relates to many in B, but each B relates to one A.
Example: One Teacher
teaches many Students
.
Â
Many-to-One (N:1)
Many entities in A relate to one in B.
Example: Many Employees
work in one Department
.
Â
Many-to-Many (M:N)
Many entities in A relate to many in B.
Example: Students enroll in many Courses
, and each Course
has many Students
.
Notation:
Typically shown near the relationship line in ER diagrams: 1, N, M, etc.
2. Participation Constraints
Participation specifies whether all instances of an entity are involved in a relationship or not.
Types:
Total Participation
Every instance must participate in the relationship.
Notation: A double line connects the entity to the relationship.
Example: Every Employee
must belong to a Department
.
Â
Partial Participation
Some instances may or may not participate.
Notation: A single line is used.
Example: Not all Students
have LibraryAccounts
.
Why it matters:
Participation tells us about mandatory or optional relationships, helping define real-world rules accurately.
3. Generalization
Generalization is a bottom-up approach where two or more similar entities are combined into a higher-level superclass based on shared characteristics.
Â
Key Points:
- Common features go into the superclass (
Vehicle
). - Specific features remain in subclasses (
Car
,Bike
). - Helps in data abstraction and reducing redundancy.
4. Specialization
Specialization is a top-down approach, where a broad entity is split into specialized sub-entities based on some distinct property.
Â
Â
Use case:
When subclasses have attributes or behavior that doesn’t apply to all members of the superclass. It helps create more accurate models.
5. Aggregation
Aggregation is used when a relationship itself needs to act as an entity. This is needed when we want to model a relationship between a relationship and another entity.
Notation:
-
A dashed rectangle is drawn around the relationship and connected to another entity.
Why it’s used:
It helps model complex situations where simple relationships are not enough—especially when relationships have attributes or participate in other relationships.
Summary Table:
Concept | Definition | Example |
---|---|---|
Cardinality | Number of allowed connections between entities | One Customer places many Orders |
Participation | Specifies if entity must participate in the relationship | All Employees must be in a Department |
Generalization | Merging similar lower entities into a superclass (bottom-up) | Car and Bike → Vehicle |
Specialization | Dividing a general entity into specific types (top-down) | Employee → Manager , Engineer |
Aggregation | Treating a relationship as an entity for another relationship | Professor guides Student on Project |