E-commerce ERD
Entity-Relationship Diagram for our e-commerce platform
erDiagram
USER ||--o{ ORDER : places
USER {
int id PK
string username
string email
string password_hash
date created_at
}
PRODUCT ||--o{ ORDER_ITEM : "contained in"
PRODUCT {
int id PK
string name
text description
decimal price
int stock
int category_id FK
}
ORDER ||--|{ ORDER_ITEM : contains
ORDER {
int id PK
int user_id FK
date order_date
string status
decimal total_amount
}
CATEGORY ||--o{ PRODUCT : has
CATEGORY {
int id PK
string name
text description
}
ORDER_ITEM {
int id PK
int order_id FK
int product_id FK
int quantity
decimal unit_price
}