Skip to content
C

Cardinality


Cardinality

Definition

Cardinality (specifically, the cardinality ratio of a relationship) specifies the number of entity instances of one entity set that can be associated with entity instances of another entity set, through a given relationship. The three classic cardinality ratios for a binary relationship are one-to-one (1:1), one-to-many (1:N), and many-to-many (M:N).

Worked Example

  • 1:1Department Headed_By Faculty: one department has exactly one head, and one faculty member heads at most one department.
  • 1:NDepartment Offers Course: one department offers many courses, but each course belongs to exactly one department.
  • M:NStudent Enrolls_In Course: one student can enroll in many courses, and one course can have many students enrolled.

In ER diagrams, cardinality is shown by labeling the lines connecting the relationship diamond to each entity set with "1", "N", or "M" (or using crow's-foot notation in some conventions).

Edge Cases

  • Cardinality is about how many instances CAN be related — a maximum/structural constraint — and must not be confused with participation (6.14), which is about whether relating is mandatory for every instance. A relationship can be 1:N with either total or partial participation on either side; the two concepts combine independently (e.g., "every course MUST belong to exactly one department" mixes 1:N cardinality with total participation on the Course side).
  • Cardinality also must not be confused with degree (6.12): degree counts entity SETS involved (2 for a binary relationship); cardinality counts entity INSTANCES that can be linked (1, N, or M) within that same binary relationship.
  • An M:N relationship, when mapped to relational tables, requires its own separate junction/linking table containing foreign keys to both entity sets (plus any relationship attributes); 1:1 and 1:N relationships can often be represented with a foreign key alone, without a separate table.
  • Some notations further refine cardinality into a (min, max) pair per side (e.g., (0,1) or (1,N)) to simultaneously capture both cardinality and participation in one notation — but conceptually the two remain distinct ideas even when combined into one symbol.

Key Takeaways / Interview Q&A

Q: In one sentence, what question does cardinality answer? A: "How many instances of entity set B can a single instance of entity set A be associated with (and vice versa)?" — answered as 1:1, 1:N, or M:N.

Q: How is an M:N relationship implemented in a relational schema? A: Via a separate junction/associative table holding foreign keys to both participating entity sets, since neither side's table can hold a variable-length list of foreign keys directly.

Q: Is cardinality the same as participation? A: No. Cardinality is about the maximum number of possible links (a structural/counting question); participation is about whether a link is mandatory at all (an existence question). A course could have 1:N cardinality with a department while still (separately) having total participation, meaning every course must have a department.

Mock Test

  • Cardinality - Quick Test

    8 questions on Cardinality.

    8 questions · 8 min · Medium
    Start Mock Test