Explain join fan-out (row explosion), how it inflates aggregates, and how to mitigate it

Quick Overview

Asks what join fan-out is, why a one-to-many join inflates sums and counts, and how to prevent it. Tests your grasp of table grain, aggregating child tables before joining, the trap of joining two child tables to one parent, and how to detect duplicated rows in SQL.

Explain join fan-out (row explosion), how it inflates aggregates, and how to mitigate it

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Other

Explain the join fan-out or row explosion problem. How can it lead to incorrect aggregate results, and how do you mitigate it? ```hint Write out the rows Take one order that has three items and list the rows the join produces. Then look at what happens to a column that belongs to the order itself. ``` ```hint Think about grain Ask what one row represents before the join and after it, and at which grain each measure should be added up. ``` ### What a Strong Answer Covers - Why a one-to-many join repeats parent rows and which measures that inflates - A small numeric example that shows the wrong total - Mitigations that restore the right grain, such as aggregating the child table before the join - What happens when two or more child tables are joined to the same parent - How to detect fan-out in a query or a data pipeline ### Follow-up Questions - Why is `SUM(DISTINCT amount)` not a safe fix? - How would you get item totals and payment totals per order in one query when both items and payments are one-to-many with orders? - How would you write a data test that catches fan-out before it reaches a dashboard? - How can a join to a dimension table that is supposed to have one row per key still fan out?

Overview: Asks what join fan-out is, why a one-to-many join inflates sums and counts, and how to prevent it. Tests your grasp of table grain, aggregating child tables before joining, the trap of joining two child tables to one parent, and how to detect duplicated rows in SQL.

General logo
General
Nov 25, 2026
mediumData ScientistOtherData Manipulation (SQL/Python)
0
0

Explain the join fan-out or row explosion problem. How can it lead to incorrect aggregate results, and how do you mitigate it?

What a Strong Answer Covers Guidance

  • Why a one-to-many join repeats parent rows and which measures that inflates
  • A small numeric example that shows the wrong total
  • Mitigations that restore the right grain, such as aggregating the child table before the join
  • What happens when two or more child tables are joined to the same parent
  • How to detect fan-out in a query or a data pipeline

Follow-up Questions Guidance

  • Why is SUM(DISTINCT amount) not a safe fix?
  • How would you get item totals and payment totals per order in one query when both items and payments are one-to-many with orders?
  • How would you write a data test that catches fan-out before it reaches a dashboard?
  • How can a join to a dimension table that is supposed to have one row per key still fan out?