Database Normalization - E-Commerce System
Before Normalization (Unnormalized Table)
Before normalization, all data is stored in a single table with redundancies and anomalies.
Example Unnormalized Table:
| OrderID | CustomerName | Email | ProductName | Seller | Quantity | Price | PaymentMethod |
ShippingAddress |
|---------|-------------|---------------|-------------|--------|----------|-------|---------------|----------------|
|1 | Ahron Leo |
[email protected] | Shoes | Nike | 2 | 5000 | Credit Card | Digos
City |
|2 | John Doe |
[email protected] | Shirt | Adidas | 1 | 2000 | PayPal | Manila
|
Step 1: First Normal Form (1NF)
1NF ensures that all columns contain atomic values and eliminates repeating groups.
- Splitting products into a separate table.
- Creating a separate Customer table.
Step 2: Second Normal Form (2NF)
2NF removes partial dependencies by ensuring non-key columns are fully dependent on the primary
key.
- Creating separate tables for Payment, Product, and Seller.
- Orders table references CustomerID.
Step 3: Third Normal Form (3NF)
3NF removes transitive dependencies, ensuring all non-key attributes only depend on the primary
key.
- Separating Shipping details into a new table.
- Creating a reference table for Payment Methods.
After Normalization: Final Normalized Tables
1. Customers (CustomerID, Name, Email)
2. Orders (OrderID, CustomerID)
3. Order_Items (OrderID, ProductID, Quantity, Price)
4. Products (ProductID, Name, SellerID, Price)
5. Sellers (SellerID, Name)
6. Payments (PaymentID, OrderID, PaymentMethodID)
7. Payment_Methods (PaymentMethodID, Method)
8. Shipping (ShippingID, OrderID, Address)