Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. What is cardinality?

Data modeling · Extra High-Value

What is cardinality?

Easymodel-30
cardinalityrelationshipsdistinct values

Question

What does cardinality mean in data modeling?

Solution

Cardinality 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
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
  • Partition 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.

PreviousNext