forked from simoncos/zhihu-analysis-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zhihu_schema.sql
42 lines (42 loc) · 1.03 KB
/
zhihu_schema.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
BEGIN TRANSACTION;
CREATE TABLE `UserTopic` (
`id` integer NOT NULL,
`user_url` text NOT NULL,
`topic` text NOT NULL,
PRIMARY KEY(id)
);
CREATE TABLE `UserQuestion` (
`id` integer NOT NULL,
`user_url` text NOT NULL,
`question_id` text NOT NULL,
PRIMARY KEY(id)
);
CREATE TABLE `User` (
`id` integer NOT NULL,
`user_url` text NOT NULL UNIQUE,
`user_id` text NOT NULL,
`followee_num` int NOT NULL,
`follower_num` int NOT NULL,
`answer_num` int NOT NULL,
`agree_num` int NOT NULL,
`thanks_num` int NOT NULL,
`layer` smallint,
`is_crawled` smallint,
PRIMARY KEY(id)
);
CREATE TABLE `Question` (
`id` integer NOT NULL,
`question_id` text NOT NULL,
`topic` text NOT NULL,
PRIMARY KEY(id)
);
CREATE TABLE `Following` (
`id` integer NOT NULL,
`user_url` text NOT NULL,
`followee_url` text NOT NULL,
PRIMARY KEY(id)
);
CREATE UNIQUE INDEX user_question on UserQuestion(user_url, question_id);
CREATE UNIQUE INDEX user_follower on following(user_url, followee_url);
CREATE UNIQUE INDEX question_topic on Question(question_id, topic);
COMMIT;