-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharticle.sql
408 lines (349 loc) · 16.5 KB
/
article.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2020/8/29 17:17:09 */
/*==============================================================*/
drop table if exists article;
drop table if exists article_tag;
drop table if exists comment;
drop table if exists feedback;
drop table if exists friendslink;
drop table if exists message;
drop table if exists oneword;
drop table if exists permission;
drop table if exists role;
drop table if exists role_permission;
drop table if exists siteinfo;
drop table if exists tag;
drop table if exists tool;
drop table if exists type;
drop table if exists user;
drop table if exists user_role;
/*==============================================================*/
/* Table: article */
/*==============================================================*/
create table article
(
id bigint not null auto_increment,
title varchar(100) comment '标题',
content text comment '内容',
description varchar(255) comment '文章描述',
first_picture varchar(255) comment '首图',
flag varchar(10) comment '原创,转载,翻译',
original_link varchar(255) comment '原文链接',
view_count int default 0 comment '查看次数',
comment_count int default 0 comment '评论数量',
like_count int default 0 comment '点赞数量',
down_count int default 0 comment '反对数量',
is_appreciated boolean comment '是否开启赞赏',
is_shared boolean comment '是否开启分享',
is_commented boolean comment '是否开启评论',
is_deleted boolean comment '是否删除',
is_recommend boolean comment '是否推荐',
is_top boolean comment '是否置顶',
is_privated boolean comment '是否仅自己可见',
is_published boolean comment '1发布,0草稿',
create_time datetime not null comment '创建时间',
update_time datetime not null comment '更新时间',
type_id bigint not null comment '类型id',
user_id bigint not null comment '作者id',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table article comment '文章';
/*==============================================================*/
/* Table: article_tag */
/*==============================================================*/
create table article_tag
(
id bigint(0) not null auto_increment,
article_id bigint not null comment '文章id',
tag_id bigint not null comment '标签id',
is_deleted boolean comment '是否删除',
primary key (id)
);
alter table article_tag comment '文章和标签';
/*==============================================================*/
/* Table: comment */
/*==============================================================*/
create table comment
(
id bigint not null auto_increment,
nickname varchar(30) comment '昵称',
email varchar(30) comment '邮箱',
avatar varchar(255) comment '头像',
content text comment '评论内容',
create_time datetime not null comment '创建时间',
is_deleted boolean comment '是否删除',
article_id bigint not null comment '文章id',
parent_id bigint comment '父评论id',
is_manager boolean comment '是否是作者',
reply_count int default 0 comment '回复数量',
like_count int default 0 comment '点赞数量',
down_count int default 0 comment '反对数量',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table comment comment '评论';
/*==============================================================*/
/* Table: feedback */
/*==============================================================*/
create table feedback
(
id bigint not null auto_increment,
url varchar(255) comment '反馈链接',
content text comment '内容',
email varchar(30) comment '邮箱',
create_time datetime not null comment '创建时间',
is_fixed boolean comment '是否修复',
is_deleted boolean comment '是否删除',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table feedback comment '反馈建议';
/*==============================================================*/
/* Table: friendslink */
/*==============================================================*/
create table friendslink
(
id int not null auto_increment,
website_url varchar(255) comment '网站地址',
website_name varchar(30) comment '网站名称',
website_description varchar(100) comment '网站简介',
picture_url varchar(255) comment '展示图片',
is_show boolean comment '是否展示',
priority int comment '优先级别',
groups varchar(10) comment '分组',
create_time datetime comment '创建时间',
update_time datetime comment '更新时间',
view_count bigint comment '浏览次数',
reserve1 int comment '预留字段1',
reserve2 int comment '预留字段2',
reserve3 varchar(255) comment '预留字段3',
reserve4 varchar(255) comment '预留字段4',
primary key (id)
);
alter table friendslink comment '友人链';
/*==============================================================*/
/* Table: message */
/*==============================================================*/
create table message
(
id bigint not null auto_increment,
nickname varchar(30) comment '昵称',
email varchar(30) comment '邮箱',
avatar varchar(255) comment '头像',
content text comment '评论内容',
create_time datetime not null comment '创建时间',
parent_id bigint comment '父评论id',
is_manager boolean comment '是否是作者',
reply_count int default 0 comment '回复数量',
is_deleted boolean comment '是否删除',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table message comment '留言';
/*==============================================================*/
/* Table: oneword */
/*==============================================================*/
create table oneword
(
id bigint not null auto_increment,
picture varchar(255) comment '图片',
content varchar(255) comment '内容',
is_deleted boolean comment '是否删除',
is_published boolean comment '是否发布',
create_time datetime not null comment '创建时间',
update_time datetime not null comment '更新时间',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table oneword comment '每日一句话';
/*==============================================================*/
/* Table: permission */
/*==============================================================*/
create table permission
(
id int not null auto_increment,
name varchar(10) not null comment '权限名称',
create_time datetime not null comment '创建时间',
update_time datetime not null comment '更新时间',
description varchar(255) comment '权限描述',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table permission comment '权限表';
/*==============================================================*/
/* Table: role */
/*==============================================================*/
create table role
(
id int not null auto_increment,
name varchar(10) not null comment '角色名称',
create_time datetime not null comment '创建时间',
update_time datetime not null comment '更新时间',
description varchar(255) comment '角色描述',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table role comment '角色表';
/*==============================================================*/
/* Table: role_permission */
/*==============================================================*/
create table role_permission
(
id bigint not null,
role_id int not null comment '角色id',
permission_id int not null comment '权限id',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table role_permission comment '角色权限表';
/*==============================================================*/
/* Table: siteinfo */
/*==============================================================*/
create table siteinfo
(
view_count bigint default 0 comment '总访问次数',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4'
);
alter table siteinfo comment '网站信息';
/*==============================================================*/
/* Table: tag */
/*==============================================================*/
create table tag
(
id bigint not null auto_increment,
name varchar(10) comment '名字',
description varchar(255) comment '描述',
create_time datetime not null comment '创建时间',
update_time datetime not null comment '更新时间',
is_deleted boolean comment '是否删除',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table tag comment '标签';
/*==============================================================*/
/* Table: tool */
/*==============================================================*/
create table tool
(
id int not null auto_increment,
name varchar(30) comment '名字',
url varchar(255) comment '链接',
create_time datetime not null comment '创建时间',
update_time datetime not null comment '更新时间',
is_deleted boolean comment '是否删除',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table tool comment '导航上的工具';
/*==============================================================*/
/* Table: type */
/*==============================================================*/
create table type
(
id bigint not null auto_increment,
name varchar(10) comment '名字',
description varchar(255) comment '描述',
create_time datetime not null comment '创建时间',
update_time datetime not null comment '更新时间',
is_deleted boolean comment '是否删除',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table type comment '分类';
/*==============================================================*/
/* Table: user */
/*==============================================================*/
create table user
(
id bigint not null,
nickname varchar(30) comment '昵称',
username varchar(30) comment '用户名',
password varchar(255) comment '密码',
email varchar(30) comment '邮箱',
phone_number varchar(20) comment '电话号码',
address varchar(50) comment '用户地址',
avatar varchar(255) comment '头像',
level int comment '用户等级',
is_manager boolean comment '是否是管理员',
create_time datetime not null comment '创建时间',
update_time datetime not null comment '更新时间',
last_login_time datetime not null comment '最后一次登录时间',
token varchar(255) comment 'cookie标记',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table user comment '用户';
/*==============================================================*/
/* Table: user_role */
/*==============================================================*/
create table user_role
(
id bigint not null,
user_id bigint not null comment '用户id',
role_id int not null comment '角色id',
reserve1 varchar(255) comment '预留字段1',
reserve2 varchar(255) comment '预留字段2',
reserve3 int comment '预留字段3',
reserve4 int comment '预留字段4',
primary key (id)
);
alter table user_role comment '用户角色表';
alter table article add constraint FK_article_fk_type_id foreign key (type_id)
references type (id) on delete restrict on update restrict;
alter table article add constraint FK_article_fk_user_id foreign key (user_id)
references user (id) on delete restrict on update restrict;
alter table article_tag add constraint FK_article_tag_fk_article_id foreign key (article_id)
references article (id) on delete restrict on update restrict;
alter table article_tag add constraint FK_article_tag_fk_tag_id foreign key (tag_id)
references tag (id) on delete restrict on update restrict;
alter table comment add constraint FK_comment_fk_article_id foreign key (article_id)
references article (id) on delete restrict on update restrict;
alter table role_permission add constraint FK_role_permission_fk_permission_id foreign key (permission_id)
references permission (id) on delete restrict on update restrict;
alter table role_permission add constraint FK_role_permission_fk_role_id foreign key (role_id)
references role (id) on delete restrict on update restrict;
alter table user_role add constraint FK_user_role_fk_role_id foreign key (role_id)
references role (id) on delete restrict on update restrict;
alter table user_role add constraint FK_user_role_fk_user_id foreign key (user_id)
references user (id) on delete restrict on update restrict;