Skip to content

Commit d464dbf

Browse files
authored
Merge pull request #196 from tebanieo/master
Updating Stage 07 on modernizr workflow
2 parents b036ff2 + 7bbe931 commit d464dbf

File tree

4 files changed

+1052
-404
lines changed

4 files changed

+1052
-404
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Entity Relationship Diagram - Modernizr E-commerce Platform
2+
3+
This diagram shows the entity relationships for the DynamoDB design based on the API access patterns analysis.
4+
5+
```mermaid
6+
erDiagram
7+
USERS {
8+
string id PK
9+
string username UK "Unique"
10+
string email UK "Unique"
11+
string password_hash
12+
string first_name
13+
string last_name
14+
boolean is_seller
15+
datetime created_at
16+
datetime updated_at
17+
}
18+
19+
CATEGORIES {
20+
string id PK
21+
string name
22+
string description
23+
string parent_id FK "Self-referencing"
24+
datetime created_at
25+
datetime updated_at
26+
}
27+
28+
PRODUCTS {
29+
string id PK
30+
string name
31+
string description
32+
decimal price
33+
integer stock_quantity
34+
string category_id FK
35+
string seller_id FK
36+
string image_url
37+
datetime created_at
38+
datetime updated_at
39+
}
40+
41+
ORDERS {
42+
string id PK
43+
string user_id FK
44+
string status
45+
decimal total_amount
46+
datetime order_date
47+
datetime updated_at
48+
string shipping_address
49+
}
50+
51+
ORDER_ITEMS {
52+
string order_id PK,FK
53+
string product_id PK,FK
54+
integer quantity
55+
decimal unit_price
56+
decimal total_price
57+
}
58+
59+
CART_ITEMS {
60+
string user_id PK,FK
61+
string product_id PK,FK
62+
integer quantity
63+
datetime added_at
64+
datetime updated_at
65+
}
66+
67+
%% User Relationships
68+
USERS ||--o{ PRODUCTS : "sells (as seller)"
69+
USERS ||--o{ ORDERS : "places (as customer)"
70+
USERS ||--o{ CART_ITEMS : "has items in cart"
71+
72+
%% Category Relationships
73+
CATEGORIES ||--o{ PRODUCTS : "contains"
74+
CATEGORIES ||--o{ CATEGORIES : "parent-child hierarchy"
75+
76+
%% Product Relationships
77+
PRODUCTS ||--o{ ORDER_ITEMS : "ordered in"
78+
PRODUCTS ||--o{ CART_ITEMS : "added to cart"
79+
80+
%% Order Relationships
81+
ORDERS ||--o{ ORDER_ITEMS : "contains items"
82+
```
83+
84+
## Key Relationship Notes:
85+
86+
### **One-to-Many Relationships:**
87+
- **Users → Products**: A seller (user) can have many products
88+
- **Users → Orders**: A customer (user) can have many orders
89+
- **Users → Cart Items**: A user can have many items in their cart
90+
- **Categories → Products**: A category can contain many products
91+
- **Products → Order Items**: A product can appear in many order items
92+
- **Products → Cart Items**: A product can be in many users' carts
93+
- **Orders → Order Items**: An order can contain many order items
94+
95+
### **Self-Referencing Relationship:**
96+
- **Categories → Categories**: Categories form a hierarchical tree structure where each category can have a parent category
97+
98+
### **Composite Primary Keys:**
99+
- **Order Items**: `(order_id, product_id)` - Links orders to products with quantities
100+
- **Cart Items**: `(user_id, product_id)` - Links users to products in their shopping cart
101+
102+
### **Unique Constraints:**
103+
- **Users**: `username` and `email` must be unique across all users
104+
105+
This entity model supports all 48 access patterns identified in the API analysis, including:
106+
- User authentication and profile management
107+
- Product catalog browsing and management
108+
- Category hierarchy navigation
109+
- Order processing and history
110+
- Shopping cart operations
111+
- Seller-specific functionality
112+
113+
The relationships enable efficient querying for complex operations like:
114+
- Product searches with category filtering
115+
- User order history with item details
116+
- Seller product management
117+
- Cart validation and checkout processing
118+
- Category breadcrumb navigation

0 commit comments

Comments
 (0)