generated from hamadsuniverse/codecatalyst-sst-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdb.dbml
61 lines (60 loc) · 1.34 KB
/
db.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
Project Ecommerce {
database_type: 'PostgreSQL'
Note: '''
# Ecommerce Database
**markdown content here**
'''
}
Table users as U {
id int [pk, increment]
full_name varchar
created_at timestamp
country_code int
note: "table 'users' contains user information"
}
Table merchants {
id int [pk]
merchant_name varchar
country_code int [note: "country of merchant"]
admin_id int [ref: > U.id]
created_at datetime [default: `now()`, note: "created time"]
note: "table 'merchants' contains merchant information"
}
Table countries {
code int [pk]
name varchar
continent_name varchar
}
Table order_items {
order_id int [ref: > orders.id]
product_id int
quantity int [default: 1]
note: 'items in an order'
}
Table orders {
id int [pk]
user_id int [not null, unique]
status varchar
created_at varchar [note: 'When order created']
}
Enum products_status {
out_of_stock
in_stock
running_low [note: 'less than 20']
}
Table products {
id int [pk]
name varchar
merchant_id int [not null]
price int
status products_status
created_at datetime [default: `now()`]
Indexes {
(merchant_id, status) [name:'product_status']
id [unique]
}
}
Ref: U.country_code > countries.code
Ref: merchants.country_code > countries.code
Ref: order_items.product_id > products.id
Ref: products.merchant_id > merchants.id