Customers return part of an order, sometimes more than once, sometimes months later. Finance needs net revenue per product — sales less returns — and it has to stay right when only two of the three units come back.
Your DDL is executed, rows are inserted into the tables you create, and queries are run against them, so the names are part of the answer:
returned BOOLEAN on fact_order_lines: it answers "was this returned" and can express neither a partial return nor a second onedim_product| product_key | product_name |
|---|---|
| 1 | Lamp |
fact_order_lines| amount | order_id | quantity | line_number | product_key |
|---|---|---|---|---|
| 200 | 10 | 2 | 1 | 1 |
fact_order_returns| amount | order_id | quantity | return_id | line_number | returned_on |
|---|---|---|---|---|---|
| 200 | 10 | 2 | 500 | 1 | 2026-02-01 |
| product_name | net_revenue |
|---|---|
| Lamp | 0 |
dim_product| product_key | product_name |
|---|---|
| 1 | Chair |
fact_order_lines| amount | order_id | quantity | line_number | product_key |
|---|---|---|---|---|
| 300 | 11 | 3 | 1 | 1 |
fact_order_returns| amount | order_id | quantity | return_id | line_number | returned_on |
|---|---|---|---|---|---|
| 100 | 11 | 1 | 501 | 1 | 2026-02-05 |
| sold | returned | net |
|---|---|---|
| 300 | 100 | 200 |
Community-reported interview topic. Not an official company question and no affiliation is implied.
Start with a table. Give it a grain, then the columns that belong at that grain.
Run against the public tests, or submit to score against all of them.