This repository contains a comprehensive database schema for an e-commerce platform developed by Power Learn Project Group 214 Cohort 7. The schema includes support for product variants, inventory management, and product attributes.
- Product Management: Core product information, categorization, and images
- Brand Management: Store and organize product manufacturers
- Category Hierarchy: Multi-level categorization for products
- Product Variations: Support for different colors and sizes
- Inventory Management: SKU-level stock tracking
- Attribute System: Flexible product specifications and features
- Built-in Views: Pre-configured views for common operations
- brand: Stores information about product manufacturers
- product_category: Hierarchical category structure for products
- product: Central product information
- product_image: Images associated with products
- color: Available color options for products
- size_category: Groups sizes into categories (clothing, shoes, etc.)
- size_option: Specific sizes within categories
- product_variation: Links products to their variations (color/size)
- product_item: Actual inventory items with SKUs and stock levels
- attribute_category: Groups product attributes into categories
- attribute_type: Defines data types for attributes
- product_attribute: Custom attributes for products
- vw_product_listing: Product listing with primary image
- vw_product_inventory: Product inventory with detailed information
- MySQL 5.7 or higher
- MySQL client or compatible database management tool
-
Clone this repository:
git clone https://github.com/alphac137/E-commerce-Database-Design.git cd E-commerce-Database-Design -
Execute the SQL files in the following order:
mysql -u alphac137 -p < part1_database_setup.sql mysql -u alphac137 -p < part2_database_setup.sql mysql -u alphac137 -p < part3_database_setup.sql mysql -u alphac137 -p < part4_database_setup.sqlAlternatively, you can use the combined script:
mysql -u alphac137 -p < ecommerce_complete.sql -
Verify the installation:
mysql -u alphac137 -p -e "USE E-commerce-Database-Design; SHOW TABLES;"
E-commerce-Database-Design/
├── part1_database_setup.sql # Database setup and core product structure
├── part2_database_setup.sql # Product attributes system
├── part3_database_setup.sql # Product variations and inventory
├── part4_database_setup.sql # Sample data and testing
├── ecommerce_complete.sql # Complete SQL script (combined)
├── doc/
│ └── ERD.png # Entity-Relationship Diagram image
└── README.md # This file
- Database creation and initial setup
- Brand table
- Product_category table
- Product table
- Product_image table
- Product listing view
- Color table
- Size_category table
- Size_option table
- Product_variation table
- Product_item table
- Inventory view
- Attribute_category table
- Attribute_type table
- Product_attribute table
- Sample data for all tables
- Testing queries
- Documentation
SELECT * FROM vw_product_listing;SELECT * FROM vw_product_inventory;SELECT p.product_name, b.brand_name, p.base_price
FROM product p
JOIN brand b ON p.brand_id = b.brand_id
WHERE p.category_id = (SELECT category_id FROM product_category WHERE category_name = 'Shoes');SELECT c.color_name, so.size_value, pi.sku, pi.stock_quantity, pi.price
FROM product_item pi
JOIN product_variation pv ON pi.variation_id = pv.variation_id
LEFT JOIN color c ON pv.color_id = c.color_id
LEFT JOIN size_option so ON pv.size_id = so.size_id
WHERE pi.product_id = 1;- All team members of Group 214 Cohort 7 for their contributions
