The E-Commerce Database Management System is a SQL-based project built with MySQL that models the backend database of an online shopping platform. It covers the core operations of an e-commerce system β user accounts, product catalogs, categories, shopping carts, orders, payments, and product reviews β all through a clean, normalized relational schema.
The goal of this project is to demonstrate solid database design principles alongside practical SQL skills: table creation, primary and foreign key relationships, joins, aggregate functions, subqueries, and views.
To design and implement a relational database that efficiently stores and manages e-commerce data, while demonstrating core SQL concepts such as table creation, relationships, joins, aggregate functions, subqueries, and views.
- π€ User Management β Store and manage customer account details
- π¦ Product Management β Maintain a catalog of products with pricing and stock info
- ποΈ Category Management β Organize products under different categories
- ποΈ Shopping Cart β Track items added by users before checkout
- π Order Management β Handle order creation and multi-product orders
- π³ Payment Tracking β Record payment method and status for each order
- β Product Reviews β Allow users to rate and review products
- ποΈ SQL Views β Simplified, reusable virtual tables for common queries
- π Basic SQL Queries β Filtering, sorting, and searching data
- π Join Queries β Combine data across multiple related tables
- π Aggregate Queries β Generate insights using SUM, AVG, COUNT, etc.
- π§ Subqueries β Handle complex, nested data retrieval
| Technology | Purpose |
|---|---|
| MySQL | Relational database management system |
| SQL | Querying, schema design, and data manipulation |
| VS Code | Development and script editing environment |
| # | Table Name | Description |
|---|---|---|
| 1 | Users |
Stores customer account information |
| 2 | Categories |
Stores product category details |
| 3 | Products |
Stores product listings and details |
| 4 | Cart |
Stores items added by users to their cart |
| 5 | Orders |
Stores order details placed by users |
| 6 | Order_Items |
Stores individual products within each order |
| 7 | Payments |
Stores payment information linked to orders |
| 8 | Reviews |
Stores user reviews and ratings for products |
|
Users
Categories
|
Products
Cart
|
Orders
Order_Items
|
Payments
Reviews
|
- π€ One user can place many orders
- ποΈ One category contains many products
- π¦ One product belongs to one category
- π One order contains multiple products through
Order_Items - π³ One order has one payment
- β One user can write multiple reviews
- β One product can receive multiple reviews
- ποΈ One user can add multiple products to the cart
E-COMMERCE-DATABASE-MANAGEMENT-SYSTEM
β
βββ π Database & Table Creation
β βββ create_database.sql
β βββ create_tables.sql
β
βββ π Data Insertion
β βββ insert_data.sql
β
βββ π Queries
β βββ basic_queries.sql
β βββ join_queries.sql
β βββ aggregate_queries.sql
β βββ subqueries.sql
β βββ views.sql
β
βββ π Images
β βββ ecommerce_er_diagram.png
β
βββ README.md
|
Database & Table Basics
|
Querying & Filtering
|
Advanced SQL
|
| Table | Records |
|---|---|
| Users | 50 |
| Categories | 8 |
| Products | 60 |
| Cart Records | 50 |
| Orders | 50 |
| Order Items | 80 |
| Payments | 50 |
| Reviews | 50 |
This project can be run either in MySQL Workbench (or the MySQL CLI) or in an online SQL editor such as OneCompiler.
git clone https://github.com/pujaripunithkumar/E-Commerce-Database-Management-System.git
cd E-Commerce-Database-Management-SystemOpen MySQL Workbench, the MySQL CLI, or VS Code with a MySQL extension, then run the scripts in order:
SOURCE "Database & Table Creation/create_database.sql";
SOURCE "Database & Table Creation/create_tables.sql";
SOURCE "Data Insertion/insert_data.sql";
SOURCE "Queries/basic_queries.sql";
SOURCE "Queries/join_queries.sql";
SOURCE "Queries/aggregate_queries.sql";
SOURCE "Queries/subqueries.sql";
SOURCE "Queries/views.sql";Most online SQL editors don't allow creating or switching databases, so you'll need to make two small adjustments:
- Skip or remove the
CREATE DATABASEstatement fromcreate_database.sql - Skip or remove the
USE database_namestatement
Then simply run the contents of create_tables.sql, followed by insert_data.sql, and finally the query files in the Queries/ folder β directly in the editor's SQL console.
β The database is now fully set up and ready to explore!
1. Retrieve all products under a specific category
SELECT p.product_name, p.price, c.category_name
FROM Products p
INNER JOIN Categories c ON p.category_id = c.category_id
WHERE c.category_name = 'Electronics';2. Find the total amount spent by each user
SELECT u.name, SUM(o.total_amount) AS total_spent
FROM Users u
INNER JOIN Orders o ON u.user_id = o.user_id
GROUP BY u.name
ORDER BY total_spent DESC;3. List the top 5 highest-rated products
SELECT p.product_name, AVG(r.rating) AS avg_rating
FROM Reviews r
INNER JOIN Products p ON r.product_id = p.product_id
GROUP BY p.product_name
ORDER BY avg_rating DESC
LIMIT 5;4. Find users who have placed more than 3 orders (Subquery + HAVING)
SELECT name
FROM Users
WHERE user_id IN (
SELECT user_id
FROM Orders
GROUP BY user_id
HAVING COUNT(order_id) > 3
);5. Create a view for order summaries
CREATE VIEW Order_Summary AS
SELECT o.order_id, u.name AS customer_name, p.product_name,
oi.quantity, oi.price, pay.payment_status
FROM Orders o
JOIN Users u ON o.user_id = u.user_id
JOIN Order_Items oi ON o.order_id = oi.order_id
JOIN Products p ON oi.product_id = p.product_id
JOIN Payments pay ON o.order_id = pay.order_id;Through this project, I practiced and demonstrated:
- β Designing normalized relational database schemas
- β Establishing primary key and foreign key relationships
- β
Writing efficient
SELECTqueries with filtering and sorting - β Performing multi-table joins to combine related data
- β Using aggregate functions for data analysis and reporting
- β Writing subqueries for complex data retrieval
- β Creating and using SQL views for simplified data access
- β Populating and managing a database with realistic sample data
- π Visualize sales and order data using a BI tool
- π§Ύ Add stored procedures and triggers for common automation tasks
- βοΈ Deploy the database on a cloud platform
- π¬ Extend the schema to track order status changes over time
The E-Commerce Database Management System demonstrates the practical application of relational database concepts in a real-world scenario. From schema design to advanced querying, this project reflects a solid understanding of SQL fundamentals and database management principles, and forms a strong foundation for building scalable, data-driven applications.
Pujari Punith Kumar B.Tech CSE (AI & ML)
GitHub: https://github.com/pujaripunithkumar
β If you found this project helpful, consider giving it a star on GitHub!