-
Notifications
You must be signed in to change notification settings - Fork 18
/
zhihudata.sql
135 lines (121 loc) · 5.38 KB
/
zhihudata.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
/*
Navicat Premium Data Transfer
Source Server : Local
Source Server Type : MySQL
Source Server Version : 50727
Source Host : localhost:3306
Source Schema : zhihudata
Target Server Type : MySQL
Target Server Version : 50727
File Encoding : 65001
Date: 26/11/2020 11:41:09
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for answer
-- ----------------------------
DROP TABLE IF EXISTS `answer`;
CREATE TABLE `answer` (
`aid` int(11) NOT NULL,
`uid` char(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`qid` int(11) NULL DEFAULT NULL,
`vote_num` int(11) NULL DEFAULT NULL,
`comment_num` int(11) NULL DEFAULT NULL,
`create_time` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`aid`) USING BTREE,
INDEX `uid_fk_idx`(`uid`) USING BTREE,
INDEX `qid_fk_idx`(`qid`) USING BTREE,
CONSTRAINT `qid_fk` FOREIGN KEY (`qid`) REFERENCES `question` (`qid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `uid_fk` FOREIGN KEY (`uid`) REFERENCES `usr` (`uid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for follow
-- ----------------------------
DROP TABLE IF EXISTS `follow`;
CREATE TABLE `follow` (
`uid` char(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`follower` char(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`follower`, `uid`) USING BTREE,
INDEX `follow_fk_idx`(`uid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for follow_topic
-- ----------------------------
DROP TABLE IF EXISTS `follow_topic`;
CREATE TABLE `follow_topic` (
`uid` char(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`tid` int(11) NOT NULL,
`contribution` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`uid`, `tid`) USING BTREE,
INDEX `tid_fk_idx`(`tid`) USING BTREE,
CONSTRAINT `tid_fk` FOREIGN KEY (`tid`) REFERENCES `topic` (`tid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `uid_ft_fk` FOREIGN KEY (`uid`) REFERENCES `usr` (`uid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for pass
-- ----------------------------
DROP TABLE IF EXISTS `pass`;
CREATE TABLE `pass` (
`uid` char(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`uid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for question
-- ----------------------------
DROP TABLE IF EXISTS `question`;
CREATE TABLE `question` (
`qid` int(11) NOT NULL,
`title` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`answer_count` int(11) NULL DEFAULT NULL,
`follower_count` int(11) NULL DEFAULT NULL,
`create_time` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`qid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for tag
-- ----------------------------
DROP TABLE IF EXISTS `tag`;
CREATE TABLE `tag` (
`qid` int(11) NOT NULL,
`tid` int(11) NOT NULL,
PRIMARY KEY (`qid`, `tid`) USING BTREE,
INDEX `tag_tid_fk_idx`(`tid`) USING BTREE,
CONSTRAINT `tag_qid_fk` FOREIGN KEY (`qid`) REFERENCES `question` (`qid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `tag_tid_fk` FOREIGN KEY (`tid`) REFERENCES `topic` (`tid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for topic
-- ----------------------------
DROP TABLE IF EXISTS `topic`;
CREATE TABLE `topic` (
`tid` int(11) NOT NULL,
`title` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`tid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for usr
-- ----------------------------
DROP TABLE IF EXISTS `usr`;
CREATE TABLE `usr` (
`uid` char(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`uname` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`utoken` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`gender` int(11) NULL DEFAULT -1,
`url` varchar(75) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`answer_count` int(11) NULL DEFAULT 0,
`articles_count` int(11) NULL DEFAULT 0,
`follower_count` int(11) NULL DEFAULT 0,
PRIMARY KEY (`uid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for wait
-- ----------------------------
DROP TABLE IF EXISTS `wait`;
CREATE TABLE `wait` (
`uid` char(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`utoken` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`url` varchar(75) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`uid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;