Skip to content

Instantly share code, notes, and snippets.

@psahni
Last active August 3, 2023 14:32
Show Gist options
  • Save psahni/dd4b09676758d1fa11c922f42baf7ba4 to your computer and use it in GitHub Desktop.
Save psahni/dd4b09676758d1fa11c922f42baf7ba4 to your computer and use it in GitHub Desktop.
db_design_e_commerce
Designing a database schema for an online merch store involves identifying the entities and their relationships. Here's a basic schema to get you started:
Entities:
Users/Customer: Information about the store's customers.
UserID (Primary Key)
Username
Email
Password (hashed)
Shipping Address
Billing Address
Phone Number
...
Products: Information about the merchandise available in the store.
ProductID (Primary Key)
Product Name
Description
Price
CategoryID (Foreign Key referencing Categories)
Stock Quantity
Product Image
...
Categories: Categories for organizing products.
CategoryID (Primary Key)
Category Name
...
Orders: Information about customer orders.
OrderID (Primary Key)
UserID (Foreign Key referencing Users)
Order Date
Total Amount
Shipping Address
Billing Address
...
Order Items: Items included in each order.
OrderItemID (Primary Key)
OrderID (Foreign Key referencing Orders)
ProductID (Foreign Key referencing Products)
Quantity
Subtotal
...
Payment: Information about customer payments for orders.
PaymentID (Primary Key)
OrderID (Foreign Key referencing Orders)
Payment Date
Payment Amount
Payment Method (e.g., Credit Card, PayPal, etc.)
...
Reviews: Customer reviews for products.
ReviewID (Primary Key)
UserID (Foreign Key referencing Users)
ProductID (Foreign Key referencing Products)
Rating
Comment
Review Date
...
This is a simplified schema to give you an idea of how the main entities would be structured. Depending on the specific requirements of your online merch store, you may need to add more tables or modify the existing ones. Also, don't forget to set appropriate constraints, indexes, and relationships to ensure data integrity and optimize performance. Additionally, consider implementing security measures like input validation and encryption for sensitive data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment