-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSQL
183 lines (149 loc) · 5.43 KB
/
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
#用户表
CREATE TABLE `account_table` (
`userId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`nickname` varchar(50) NOT NULL DEFAULT '',
`portrait` varchar(255) DEFAULT '',
`gender` int(5) NOT NULL DEFAULT '0',
`birthday` date NOT NULL,
`mobile` varchar(30) NOT NULL DEFAULT '',
`date` datetime NOT NULL,
`level` int(5) NOT NULL DEFAULT '1',
`password` varchar(256) CHARACTER SET latin1 NOT NULL DEFAULT '',
PRIMARY KEY (`userId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#帖子表
CREATE TABLE `post_table` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`authorId` int(20) unsigned NOT NULL,
`isPrivate` tinyint(1) NOT NULL,
`postDate` datetime NOT NULL,
`image` varchar(255) DEFAULT '',
`content` mediumtext NOT NULL,
`labelId` int(20) unsigned DEFAULT '0',
`famousId` int(20) unsigned DEFAULT '0',
`bookId` int(20) unsigned DEFAULT '0',
`postType` int(5) NOT NULL DEFAULT '0',
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8;
#评论表
CREATE TABLE `comment_table` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`postId` int(20) unsigned NOT NULL,
`content` mediumtext NOT NULL,
`authorId` int(20) unsigned NOT NULL,
`replyId` int(20) unsigned NOT NULL,
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#收藏夹表
CREATE TABLE `collect_table` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL DEFAULT '',
`cover` varchar(255) DEFAULT '',
`authorId` int(20) unsigned NOT NULL,
`isPrivate` tinyint(1) NOT NULL,
`introduction` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#标签表
CREATE TABLE `label_table` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(20) NOT NULL DEFAULT '',
`cover` varchar(255) DEFAULT '',
`authorId` int(20) unsigned NOT NULL,
`status` int(5) NOT NULL DEFAULT '0',
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#名人表
CREATE TABLE `famous_table` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`authorId` int(20) unsigned NOT NULL,
`introduction` varchar(512) NOT NULL DEFAULT '',
`name` varchar(20) NOT NULL DEFAULT '',
`cover` varchar(255) DEFAULT '',
`status` int(5) NOT NULL DEFAULT '0',
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#书籍表
CREATE TABLE `book_table` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`authorId` int(20) unsigned NOT NULL,
`introduction` varchar(512) NOT NULL DEFAULT '',
`name` varchar(20) NOT NULL DEFAULT '',
`cover` varchar(255) DEFAULT '',
`status` int(5) NOT NULL DEFAULT '0',
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#举报用户表
CREATE TABLE `report_user` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`authorId` int(20) unsigned NOT NULL,
`userId` int(20) unsigned NOT NULL,
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#举报帖子表
CREATE TABLE `report_post` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`authorId` int(20) unsigned NOT NULL,
`postId` int(20) unsigned NOT NULL,
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#举报评论表
CREATE TABLE `report_comment` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`authorId` int(20) unsigned NOT NULL,
`commentId` int(20) unsigned NOT NULL,
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#收藏帖子表
CREATE TABLE `collect_post` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`postId` int(20) unsigned NOT NULL,
`collectId` int(20) unsigned NOT NULL,
`authorId` int(20) unsigned NOT NULL,
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#点赞帖子表
CREATE TABLE `praise_post` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`postId` int(20) unsigned NOT NULL,
`authorId` int(20) unsigned NOT NULL,
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#点赞评论表
CREATE TABLE `praise_comment` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`commentId` int(20) unsigned NOT NULL,
`authorId` int(20) unsigned NOT NULL,
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#帖子标签表
CREATE TABLE `label_post` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`postId` int(20) unsigned NOT NULL,
`labelId` int(20) unsigned NOT NULL,
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#帖子名人表
CREATE TABLE `famous_post` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`postId` int(20) unsigned NOT NULL,
`famousId` int(20) unsigned NOT NULL,
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#帖子出处(书籍)表
CREATE TABLE `book_post` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`postId` int(20) unsigned NOT NULL,
`bookId` int(20) unsigned NOT NULL,
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
#关注、粉丝表
# A 关注 B --- authorId==A && userId==B >> count!=0
# A 的粉丝列表 where userId==A
# A 的关注列表 where authorId==A
CREATE TABLE `attention_fan` (
`objectId` int(20) unsigned NOT NULL AUTO_INCREMENT,
`authorId` int(20) unsigned NOT NULL,
`userId` int(20) unsigned NOT NULL,
PRIMARY KEY (`objectId`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;