A shop wants two numbers from the same warehouse:
Model it so both are right at once.
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:
count(distinct order_id) must give the number of ordersdim_product| product_key | product_name |
|---|---|
| 1 | Keyboard |
| 2 | Monitor |
fact_order_lines| amount | order_id | quantity | line_number | product_key |
|---|---|---|---|---|
| 50 | 100 | 2 | 1 | 1 |
| 200 | 100 | 1 | 2 | 2 |
| 25 | 101 | 1 | 1 | 1 |
| product_name | revenue |
|---|---|
| Keyboard | 75 |
| Monitor | 200 |
dim_product| product_key | product_name |
|---|---|
| 1 | Cable |
fact_order_lines| amount | order_id | quantity | line_number | product_key |
|---|---|---|---|---|
| 10 | 200 | 1 | 1 | 1 |
| 10 | 200 | 1 | 2 | 1 |
| 10 | 200 | 1 | 3 | 1 |
| orders | lines |
|---|---|
| 1 | 3 |
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.