-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcilicili.sql
120 lines (119 loc) · 3.06 KB
/
cilicili.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
114
115
116
117
118
119
120
CREATE DATABASE cilicili;
USE cilicili;
CREATE TABLE users (
uid BIGINT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(32) NOT NULL UNIQUE,
pwd VARCHAR(200) NOT NULL,
nickname VARCHAR(32),
sex VARCHAR(2) NOT NULL,
email VARCHAR(30),
phone CHAR(11),
signature VARCHAR(200),
coins INT NOT NULL DEFAULT 0,
regtime DATETIME NOT NULL,
birth DATE,
roles INT NOT NULL DEFAULT 0,
islocked INT NOT NULL DEFAULT 0,
avatar VARCHAR(100) NOT NULL DEFAULT 'default.jpg',
deleted INT(2) DEFAULT 0,
CHECK(sex IN ('男','女','保密'))
);
CREATE TABLE video(
vid BIGINT PRIMARY KEY AUTO_INCREMENT,
vtitle VARCHAR(50) NOT NULL,
vpart INT NOT NULL,
vinfo VARCHAR(1000),
vowner BIGINT NOT NULL,
uptime DATETIME NOT NULL,
vviews BIGINT NOT NULL DEFAULT 0,
videofile VARCHAR(100) NOT NULL,
vlikes INT NOT NULL DEFAULT 0,
vcoins INT NOT NULL DEFAULT 0,
vcolnum INT NOT NULL DEFAULT 0,
vimage VARCHAR(100) NOT NULL DEFAULT 'default.jpg',
deleted INT(2) DEFAULT 0,
islocked INT NOT NULL DEFAULT 1,
FOREIGN KEY (vowner) REFERENCES users(uid)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE comments(
comid BIGINT PRIMARY KEY AUTO_INCREMENT,
comvid BIGINT NOT NULL,
comown BIGINT NOT NULL,
comcontent VARCHAR(1000) NOT NULL,
comtime DATETIME NOT NULL,
comlikes INT NOT NULL DEFAULT 0,
deleted INT(2) DEFAULT 0,
FOREIGN KEY (comvid) REFERENCES video(vid)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (comown) REFERENCES users(uid)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE commentreply(
rid BIGINT PRIMARY KEY AUTO_INCREMENT,
recomid BIGINT NOT NULL,
rown BIGINT NOT NULL,
replied BIGINT NOT NULL,
rcontent VARCHAR(1000) NOT NULL,
rtime DATETIME NOT NULL,
rlikes INT NOT NULL DEFAULT 0,
deleted INT(2) DEFAULT 0,
FOREIGN KEY (recomid) REFERENCES comments(comid)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (recomid) REFERENCES commentreply(rid)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (rown) REFERENCES users(uid)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (replied) REFERENCES users(uid)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE danmu(
did BIGINT PRIMARY KEY AUTO_INCREMENT,
dvid BIGINT NOT NULL,
duid BIGINT NOT NULL,
dcontent VARCHAR(255) NOT NULL,
dsize INT,
color INT,
dtime FLOAT(11,0),
dposition INT,
FOREIGN KEY (dvid) REFERENCES video(vid)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (duid) REFERENCES users(uid)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE collection(
colid BIGINT PRIMARY KEY AUTO_INCREMENT,
colu BIGINT NOT NULL,
colv BIGINT NOT NULL,
coltime DATETIME NOT NULL,
deleted INT(2) DEFAULT 0,
FOREIGN KEY (colu) REFERENCES users(uid)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (colv) REFERENCES video(vid)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE follow(
fid BIGINT PRIMARY KEY AUTO_INCREMENT,
follower BIGINT NOT NULL,
followed BIGINT NOT NULL,
followtime DATETIME NOT NULL,
deleted INT(2) DEFAULT 0,
FOREIGN KEY (follower) REFERENCES users(uid)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (followed) REFERENCES users(uid)
ON DELETE CASCADE
ON UPDATE CASCADE
);
INSERT INTO users(username,pwd,sex,regtime,roles) VALUES('admin','admin','男',NOW(),2);