-
Notifications
You must be signed in to change notification settings - Fork 4
/
db-structure.dbml
72 lines (64 loc) · 1.53 KB
/
db-structure.dbml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Docs: https://dbml.dbdiagram.io/docs
Table users {
id serial [pk, increment]
email_address varchar(100) [not null, unique]
hashed_pw text
auth_method varchar(50) [not null]
}
Table addresses {
id serial [pk, increment]
address varchar(300) [not null]
postcode varchar(8) [not null]
indexes {
(address, postcode) [unique]
}
}
Table products {
id serial [pk, increment]
name varchar(100) [not null]
price money [not null]
stock_count integer [not null]
available_stock_count integer [not null]
short_description varchar(200)
long_description text
size varchar(25)
avg_rating decimal(3, 2)
rating_count integer
}
Table cart_products {
user_id integer [ref: > users.id]
product_id integer [ref: > products.id]
quantity smallint [not null, default: 1]
indexes {
(user_id, product_id) [pk]
}
}
Table orders {
id serial [pk, increment]
user_id integer [ref: > users.id]
address_id integer [ref: > addresses.id]
order_placed_time timestamp [not null]
status varchar(100) [not null]
total_cost money [not null]
}
Table order_products {
order_id integer [ref: > orders.id]
product_id integer [ref: > products.id]
product_quantity smallint [not null, default: 1]
indexes {
(order_id, product_id) [pk]
}
}
Table categories {
id serial [pk, increment]
name varchar(100) [not null]
description text
url_slug varchar(50)
}
Table product_categories {
product_id integer [ref: > products.id]
category_id integer [ref: > categories.id]
indexes {
(product_id, category_id) [pk]
}
}