-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.sql
More file actions
36 lines (35 loc) · 900 Bytes
/
Copy pathdb.sql
File metadata and controls
36 lines (35 loc) · 900 Bytes
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
create table user(
user_id int not null auto_increment,
username varchar(20),
displayname varchar(20),
password varchar(60),
primary key(user_id),
unique (username)
);
--
create table room(
room_id int not null auto_increment,
roomname varchar(20),
primary key(room_id),
unique (roomname)
);
--
create table message(
message_id int not null auto_increment,
content text,
sender_id int not null,
room_id int not null,
time timestamp not null,
primary key (message_id),
foreign key (sender_id) references user (user_id),
foreign key (room_id) references room (room_id)
);
--
create table user_room(
user_id int not null,
room_id int not null,
last_message_id int not null,
primary key (user_id, room_id),
foreign key (user_id) references user (user_id),
foreign key (room_id) references room (room_id)
);