-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathso-create.sql
executable file
·94 lines (83 loc) · 4 KB
/
so-create.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
ALTER TABLE Comments DROP CONSTRAINT comments_id_fkey;
DROP TABLE Votes;
DROP TABLE Tags;
DROP TABLE Posts;
DROP TABLE Comments;
DROP TABLE Users;
DROP TABLE PostLinks;
DROP TABLE PostHistory;
DROP TABLE Badges;
CREATE TABLE Users (
id INTEGER UNIQUE NOT NULL, --Id
reputation INTEGER NOT NULL, --Reputation
creation TIMESTAMP NOT NULL, --CreationDate
name TEXT, --DisplayName Yes, can be null some times
lastaccess TIMESTAMP, --LastAccessDate
website TEXT, --WebsiteUrl
location TEXT, --Location
aboutme TEXT, --AboutMe
views INTEGER, --Views
upvotes INTEGER, --upvotes
downvotes INTEGER, --downvotes
age INTEGER --age
);
CREATE TABLE Comments (
id INTEGER UNIQUE NOT NULL, --Id
postid INTEGER NOT NULL, --PostId
score INTEGER, --Score
text TEXT, --Text
creation TIMESTAMP NOT NULL, --CreationDate
userid INTEGER --UserId
);
CREATE TABLE Posts (
id INTEGER UNIQUE NOT NULL, --Id
type INTEGER NOT NULL, --PostTypeId
creation TIMESTAMP NOT NULL, --CreationDate
score INTEGER, --Score
viewcount INTEGER, --ViewCount
title TEXT, --Title
body TEXT, --Body
userid INTEGER, --OwnerUserId
lastactivity TIMESTAMP, --LastActivityDate
tags TEXT, --Tags
answercount INTEGER, --AnswerCount
commentcount INTEGER --CommentCount
);
CREATE TABLE Tags (
id INTEGER UNIQUE NOT NULL, --Id
name TEXT UNIQUE NOT NULL, --TagName
count INTEGER, --Count
excerptpost INTEGER, --ExcerptPostId
wikipost INTEGER --WikiPostId
);
CREATE TABLE Votes (
id INTEGER UNIQUE NOT NULL, --Id
type INTEGER NOT NULL, --VoteTypeId
postid INTEGER NOT NULL, --PostId
creation DATE NOT NULL --CreationDate
);
CREATE TABLE PostLinks (
id INTEGER UNIQUE NOT NULL, --Id
creation TIMESTAMP NOT NULL, --CreationDate
postid INTEGER, --PostId
relatedpostid INTEGER, --RelatedPostId
linktypeid INTEGER --LinkTypeId
);
CREATE TABLE PostHistory (
id INTEGER UNIQUE NOT NULL, --Id
type INTEGER, --PostHistoryTypeId
postid INTEGER, --PostId
revisionguid TEXT, --RevisionGUID
creation TIMESTAMP NOT NULL, --CreationDate
userid INTEGER, --UserId
userdisplaymame TEXT, --UserDisplayName
text TEXT --Text
);
CREATE TABLE Badges (
id INTEGER UNIQUE NOT NULL, --Id
userid INTEGER, --UserId
name TEXT, --Name
date TIMESTAMP, --Date
badgeclass INTEGER, --Class
tagbased TEXT --TagBased
);