Data modeling · Extra High-Value

What is cardinality?

Easycardinalityrelationshipsdistinct values

Interview question

What does cardinality mean in data modeling?

How to answer

The short answer

describes how many related rows can exist on each side of a relationship, and relatedly, how many distinct values a column has.

Relationship cardinality

  • One-to-one: person ↔ passport number
  • One-to-many: customer ↔ orders
  • Many-to-many: student ↔ courses
Output
customer (1) ----< (many) orders

Column cardinality

  • Low: country_code (hundreds of values)
  • High: user_id, email (millions)

Why DEs care

  • Join design and fan-out risk
  • and Z-order choices (avoid ultra-high-cardinality partition keys)
  • Bridge tables for many-to-many
  • Estimate of junk-dimension size (product of low-cardinality flags)

Interview tip

Clarify whether they mean relationship cardinality or distinct-value cardinality, then give both briefly if unsure.