Explain how you would model sales transactions using a star schema with a fact table and dimension tables.
Use the provided sales fact, product dimension, and date dimension structures. Write a PostgreSQL query that demonstrates the model by summarizing completed sales from the first quarter of 2025.
Output
- One row per calendar month and product category.
- Return
month_start, category, transaction_count, total_quantity, and total_sales.
- Include unmatched products as
Unknown, exclude canceled sales and dates outside the quarter, and sort by month_start then category.
Output details
- Sort both
month_start and category in ascending order.
- Treat NULL
quantity and NULL unit_price values as 0.
- Map NULL product categories to
Unknown as well as unmatched products.
- Count every qualifying sales row without deduplication.