Project 1: Multi-Table E-Commerce Platform Database
Project 1: Multi-Table E-Commerce Platform Database
Capstone Project 1: Multi-Table E-Commerce Platform Database
Welcome to the first Intermediate Capstone Project! In this comprehensive hands-on project, you will design, implement, populate, and query a production-ready Relational E-Commerce Database.
You will bridge everything learned across multi-table relationships, foreign key cascade constraints, multi-table joins, views, and Common Table Expressions.
1. Architectural Schema Design
Our platform consists of 5 normalized relational tables:
- 1
customers: Core user identity and contact details. - 2
categories: Self-referencing hierarchical product categories. - 3
products: Catalog items linked to categories. - 4
orders: Order headers linked to customers. - 5
order_items: Line-item junction table bridging orders and products with historical prices.
2. Complete DDL Implementation Script
3. Inserting Realistic Seed Data
4. Advanced Analytics & Production Queries
Query A: Customer Lifetime Value (LTV) with Revenue Ranking
Query B: Product Gross Margin & Sales Velocity View
Multiple Choice Questions
1. Why does order_items store unit_price when products table already contains retail_price?
A. MySQL requires all numbers to be duplicated B. To preserve the historical price at the moment of purchase even if product price changes in the future C. Because order_items cannot hold foreign keys D. To speed up full table scans Answer: B Explanation: Product prices fluctuate over time. Capturing unit_price in order_items preserves accurate historical billing records.
2. In our schema, what happens to order_items when an order is deleted, based on ON DELETE CASCADE?
A. The deletion is rejected with an error B. All corresponding child line items in order_items are automatically deleted C. The product records are deleted D. The customer is notified by email Answer: B Explanation: ON DELETE CASCADE guarantees that deleting an order removes all associated line items in order_items automatically.
3. What relationship exists between orders and products?
A. One-to-One (1:1) B. One-to-Many (1:N) C. Many-to-Many (M:N) mediated by order_items D. Self-referencing recursive Answer: C Explanation: Orders and Products share an M:N relationship, where one order contains multiple products and one product appears in multiple orders via the order_items junction table.
4. Which category relationship model was implemented in categories?
A. Many-to-Many cross join B. Self-referencing recursive hierarchy via parent_id C. Star schema dimension D. JSON array column Answer: B Explanation: The categories table uses a self-referencing foreign key (parent_id REFERENCES categories(category_id)) to model arbitrary tree depths.
5. Why is ON DELETE RESTRICT specified on the customer_id foreign key in orders?
A. To prevent deleting customers who have existing purchase history B. To force customer accounts to renew annually C. To prevent customers from ordering twice D. To disable indexes on customers Answer: A Explanation: ON DELETE RESTRICT guarantees referential integrity by preventing deletion of customer records that have associated historical orders.
Project 2: Banking Transaction & Ledger System with ACID Guarantees
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
| Previous Lesson | Next Lesson |
|---|---|
| Password Management & Account Locking | Project 2: Banking Transaction & Ledger System with ACID Guarantees |
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.