-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.sql
115 lines (105 loc) · 3.34 KB
/
script.sql
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
create table if not exists ChatGroups
(
ChatID int(20) auto_increment
primary key,
Name varchar(50) null
);
create table if not exists Users
(
UserID int auto_increment
primary key,
FirstName varchar(15) not null,
LastName varchar(20) not null,
Email char(30) not null,
Password char(30) not null,
Dob date not null,
Avatar text null,
LastOnline datetime null,
constraint Users_Email_uindex
unique (Email)
);
create table if not exists ChatMessages
(
MessID int(25) auto_increment
primary key,
ChatID int(20) not null,
UserID int(10) not null,
Content text not null,
Time datetime not null,
constraint ChatMessages_ChatGroups_ChatID_fk
foreign key (ChatID) references ChatGroups (ChatID),
constraint ChatMessages_Users_UserID_fk
foreign key (UserID) references Users (UserID)
);
create table if not exists ChatMembers
(
ChatID int(20) not null,
UserID int(10) not null,
LSMessID int(25) null,
Name varchar(50) not null,
primary key (ChatID, UserID),
constraint ChatMembers_ChatGroups_ChatID_fk
foreign key (ChatID) references ChatGroups (ChatID),
constraint ChatMembers_ChatMessages_MessID_fk
foreign key (LSMessID) references ChatMessages (MessID),
constraint ChatMembers_Users_UserID_fk
foreign key (UserID) references Users (UserID)
);
create table if not exists Stories
(
StoryID int(13) auto_increment
primary key,
UserID int(10) not null,
Content text not null,
Time datetime not null,
constraint Stories_Users_UserID_fk
foreign key (UserID) references Users (UserID)
);
create table if not exists Comments
(
CommentID int(16) auto_increment
primary key,
StoryID int(13) not null,
UserID int(10) not null,
Content text not null,
Time datetime not null,
constraint Comments_Stories_StoryID_fk
foreign key (StoryID) references Stories (StoryID),
constraint Comments_Users_UserID_fk
foreign key (UserID) references Users (UserID)
);
create table if not exists ReactComments
(
RCID int(20) auto_increment
primary key,
CommentID int(16) not null,
UserID int(10) not null,
Type int(2) not null,
constraint ReactComments_Comments_CommentID_fk
foreign key (CommentID) references Comments (CommentID)
);
create table if not exists ReactStories
(
RSID int(18) auto_increment
primary key,
StoryID int(13) not null,
UserID int(10) not null,
Type int(2) not null,
constraint ReactStories_Stories_StoryID_fk
foreign key (StoryID) references Stories (StoryID)
);
create table if not exists Announcements
(
UserID int(10) not null,
AID int(25) not null,
Type int(2) not null,
Time datetime not null,
constraint Announcements_Comments_CommentID_fk
foreign key (AID) references Comments (CommentID),
constraint Announcements_ReactComments_RCID_fk
foreign key (AID) references ReactComments (RCID),
constraint Announcements_ReactStories_RSID_fk
foreign key (AID) references ReactStories (RSID),
constraint Announcements_Users_UserID_fk
foreign key (UserID) references Users (UserID)
);