Skip to content

Commit 90f0844

Browse files
committed
docs: erd
1 parent 24d4458 commit 90f0844

1 file changed

Lines changed: 98 additions & 0 deletions

File tree

docs/week2/004-erd.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
```mermaid
2+
erDiagram
3+
users {
4+
bigint id PK
5+
varchar user_id UK
6+
varchar email UK
7+
varchar gender
8+
date birthday
9+
timestamp created_at
10+
timestamp updated_at
11+
timestamp deleted_at
12+
}
13+
products {
14+
bigint id PK
15+
varchar name
16+
bigint price
17+
bigint brand_id FK
18+
timestamp created_at
19+
timestamp updated_at
20+
timestamp deleted_at
21+
}
22+
stocks {
23+
bigint id PK
24+
int quantity
25+
bigint product_id FK
26+
timestamp created_at
27+
timestamp updated_at
28+
}
29+
stock_histories {
30+
bigint id PK
31+
int before_quantity
32+
int quantity
33+
int after_quantity
34+
varchar stock_type
35+
bigint stock_id FK
36+
timestamp created_at
37+
timestamp updated_at
38+
}
39+
brands {
40+
bigint id PK
41+
varchar name
42+
timestamp created_at
43+
timestamp updated_at
44+
timestamp deleted_at
45+
}
46+
likes {
47+
bigint user_id PK, FK
48+
bigint product_id PK, FK
49+
timestamp created_at
50+
timestamp updated_at
51+
}
52+
points {
53+
bigint id PK
54+
bigint point
55+
bigint user_id FK
56+
timestamp created_at
57+
timestamp updated_at
58+
timestamp deleted_at
59+
}
60+
point_histories {
61+
bigint id PK
62+
bigint before_point
63+
bigint amount
64+
bigint after_point
65+
varchar point_type
66+
bigint point_id FK
67+
timestamp created_at
68+
timestamp updated_at
69+
}
70+
orders {
71+
bigint id PK
72+
bigint total_price
73+
varchar order_status
74+
bigint user_id FK
75+
timestamp created_at
76+
timestamp updated_at
77+
}
78+
order_items {
79+
bigint id PK
80+
int quantity
81+
varchar product_name
82+
bigint product_price
83+
bigint order_id FK
84+
bigint product_id FK
85+
timestamp created_at
86+
timestamp updated_at
87+
}
88+
89+
users ||--o{ likes: ""
90+
users ||--o{ points: ""
91+
users ||--o{ orders: ""
92+
brands ||--o{ products: ""
93+
products ||--|| stocks: ""
94+
stocks ||--o{ stock_histories: ""
95+
points ||--o{ point_histories: ""
96+
orders ||--o{ order_items: ""
97+
products ||--o{ likes: ""
98+
```

0 commit comments

Comments
 (0)