This project demonstrates an advanced e-commerce database system using SQL. It includes tables for managing customers, products, orders, suppliers, categories, and order details. The project showcases various SQL queries to retrieve useful insights and reports from the database.
- Project Overview
- Database Schema
- Sample Data
- Project Structure
- How to Use
- Examples of Queries
- Contributing
- License
CategoryID: INT, Primary KeyCategoryName: VARCHAR(50)Descriptions: VARCHAR(255)
SupplierID: INT, Primary KeySupplierName: VARCHAR(100)ContactName: VARCHAR(50)StreetAddress: VARCHAR(255)City: VARCHAR(50)Country: VARCHAR(50)Phone: VARCHAR(20)
ProductID: INT, Primary KeyProductName: VARCHAR(100)CategoryID: INT, Foreign KeySupplierID: INT, Foreign KeyPrice: DECIMAL(10, 2)StockQuantity: INT
CustomerID: INT, Primary KeyFirstName: VARCHAR(50)LastName: VARCHAR(50)Email: VARCHAR(100)Phone: VARCHAR(20)StreetAddress: VARCHAR(255)City: VARCHAR(50)Country: VARCHAR(50)
OrderID: INT, Primary KeyOrderDate: DATECustomerID: INT, Foreign KeyTotalAmount: DECIMAL(10, 2)
OrderDetailID: INT, Primary KeyOrderID: INT, Foreign KeyProductID: INT, Foreign KeyQuantity: INTUnitPrice: DECIMAL(10, 2)
- Electronics
- Clothing
- Home & Kitchen
- Books
- Sports
- TechSupplier
- FashionSupplier
- HomeSupplier
- BookSupplier
- SportsSupplier
- Laptop, Smartphone, Jeans, T-Shirt, Blender, Toaster, Fiction Book, Science Book, Football, Tennis Racket
- Alice Thomas, Jane Smith, Emily Clark, Mark Taylor, Laura Wilson, Hollie Barker
- 5 orders placed with varying amounts
- Details of products ordered with quantities and prices
The project repository is structured as follows:
sql-ecommerce-database/
│
├── create_tables.sql # SQL script to create tables
├── insert_data.sql # SQL script to insert sample data
├── queries.sql # SQL script with all the advanced queries
├── README.md # Project overview and documentation
└── screenshots/ # Folder containing screenshots of query results
├── query1_result.png
├── query2_result.png
└── ...
To set up the database:
- Execute
create_tables.sqlto create the database schema. - Execute
insert_data.sqlto populate the tables with sample data.
To run queries:
- Execute the queries in
queries.sqlto analyze different aspects of the eCommerce database.
Here are some examples of the SQL queries included:
- Retrieve all customers who have placed orders.
- Listdown all products with their category and supplier information.
- Calculate total sales per product category.
- Listdown the Product Popularity (by no. of Quantity sold).
- Calculate average order value per customer.
- Listdown Orders with Total Quantity and Total Price of Products in Each Order.
- Listdown All Suppliers with Their Products and the Total Stock Quantity.
- Get Total Revenue Generated by Each Supplier.
- Find Customers Who Have Placed Orders Exceeding 100 GBP.
- Listdown Products with Less Than 50 Units in Stock.
- Calculate Average Order Value per Month.
- Listdown All Products Sold in a Specific Month.
- Calculate the Total Number of Orders Placed by Each Customer.
Feel free to contribute to this project by suggesting improvements, optimizing queries, or adding new features. Fork the repository, make your changes, and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.