Beginner

537. JOIN Cardinality

Understand one-to-one, one-to-many, and many-to-many relationships and their effect on JOIN results.

📘 Lesson 537 of 728 ⏱ 13 min 🎯 Advanced

JOIN cardinality describes how many rows from one table can relate to rows in another table. Common relationships include one-to-one, one-to-many, and many-to-many.

Understanding cardinality helps predict result size and prevents incorrect aggregations and duplicate results.

One customer can have many orders, representing a one-to-many relationship.

SQL
SELECT
    c.CustomerName,
    COUNT(o.OrderID) AS OrderCount
FROM Customers c
LEFT JOIN Orders o
    ON c.CustomerID = o.CustomerID
GROUP BY c.CustomerName;

Essential for database design, SQL analysis, data modeling, Power BI relationships, and reporting.

  • One-to-one means one record matches one record.
  • One-to-many means one record can match many records.
  • Many-to-many relationships require careful modeling.
  • Cardinality affects JOIN result size.
  • Incorrect assumptions can cause incorrect calculations.
What is JOIN cardinality?

JOIN cardinality describes how records in one table relate to records in another table.

Why is cardinality important?

It helps predict result size and prevents incorrect calculations caused by unexpected multiple matches.

Have you finished this lesson?

Introduction to SQL – All Lessons