Sales reports for a shop

The problem

Build the database for a small shop's products, customers and orders, and write the reports the owner needs to run the business.

Requirements

Technologies

Step by step

  1. Design the four tables and the relationships between them.
  2. Insert sample data covering several months, customers and products.
  3. Write the monthly report with GROUP BY on the month.
  4. Write the product reports, using LEFT JOIN for products that have not sold.
  5. Write the customer reports, with COALESCE for customers with no orders.
  6. Label customers with CASE, using a subquery for each customer's order count.
  7. Add indexes, and compare the query plans before and after.

Expected result

A shop database and a set of reports that answer the owner's questions correctly.

How it is evaluated

Ways to improve it