-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.dbml
38 lines (32 loc) · 907 Bytes
/
schema.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
Table Users {
user_id SERIAL [pk]
username VARCHAR(50) [not null]
password VARCHAR(100) [not null]
}
Table Messages {
message_id SERIAL [pk]
sender_id INTEGER [not null, ref: > Users.user_id]
receiver_id INTEGER [not null, ref: > Users.user_id]
message_text TEXT [not null]
read BOOLEAN [default: false]
sent_at TIMESTAMP [default: `CURRENT_TIMESTAMP`]
}
Table Channel
(
chanel_id SERIAL [pk]
owner_id INTEGER NOT NULL [not null, ref: > Users.user_id]
chanel_name VARCHAR(50) UNIQUE NOT NULL
);
Table ChannelUsers
(
chanel_user_id SERIAL [pk]
chanel_id INTEGER [not null, ref: > Channel.chanel_id]
user_id INTEGER [not null, ref: > Users.user_id]
);
Table ChannelMessages
(
chanel_message_id SERIAL [pk]
chanel_id INTEGER NOT NULL [not null, ref: > Channel.chanel_id]
message_text TEXT NOT NULL,
sent_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);