E-Commerce Orders and Inventory Schema
Design a multi-table schema covering customers, products, orders, order items, and inventory, then write reporting queries such as best-selling products and revenue by category. Learners practice multi-table joins, subqueries, and transaction-safe stock decrement logic.
- Estimate
- ~10.5h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
PostgreSQL · pgAdmin
Project roadmap
- 01
Design the full schema
~2hCreate customers, products, categories, orders, order_items, and inventory tables with foreign keys.
- 02
Insert realistic sample data
~1.5hPopulate all tables with a coherent set of customers, products, and multi-item orders.
- 03
Report revenue by category
~2hWrite a multi-table join query computing total revenue grouped by product category.
- 04
Find inactive customers
~1.5hUse a subquery to find customers with no orders in the last 90 days.
- 05
Write a stock-decrement transaction
~2hWrite a transaction that inserts an order and decrements inventory atomically, rolling back on insufficient stock.
- 06
Add indexes and analyze plans
~1.5hAdd appropriate indexes and use EXPLAIN to verify the reporting queries use them.
Resources
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack