Relationship Cardinality: One-to-One and One-to-Many
You'll learn how to express constraints on how many instances can participate in a database relationship.
What Is Cardinality?
In ER modeling, cardinality defines how many instances of one entity can be associated with instances of another entity. It answers questions like "Can one customer place many orders?" or "Does each employee have exactly one manager?" Understanding cardinality helps you design accurate database schemas that reflect real-world rules.
One-to-One (1:1) Relationships
A one-to-one relationship means each instance of Entity A relates to at most one instance of Entity B, and vice versa.
Example: A Person has exactly one Passport, and each Passport belongs to exactly one Person.
Think of it like monogamous marriage: one person paired with one other person. In ER diagrams, you mark both sides with "1" to show this constraint.
One-to-Many (1:N) Relationships
A one-to-many relationship means one instance of Entity A can relate to multiple instances of Entity B, but each B relates to only one A.
Example: A Department has many Employees, but each Employee works in only one Department.
This is like a parent with children: one parent, many kids, but each child has just one biological mother. In ER diagrams, you mark one side with "1" and the other with "N" (or "M").
Why It Matters
Cardinality constraints guide how you implement foreign keys. In a one-to-many relationship, the foreign key goes on the "many" side (Employees table stores department_id). In one-to-one, either side can hold the foreign key, though you'll add uniqueness constraints.
Key Takeaway: Cardinality constraints (1:1 and 1:N) specify how many entity instances can participate in a relationship, shaping your database design and foreign key placement.