-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBuildMainDB.sql
159 lines (134 loc) · 3.44 KB
/
BuildMainDB.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
--
-- File generated with SQLiteStudio v3.2.1 on Sun Jun 16 21:50:55 2019
--
-- Text encoding used: System
--
PRAGMA foreign_keys = off;
BEGIN TRANSACTION;
-- Table: ApplicationStatus
DROP TABLE IF EXISTS ApplicationStatus;
CREATE TABLE ApplicationStatus (
LastRunStart DATETIME,
LastRunEnd DATETIME,
RunNumber INTEGER,
NumberOfComments BIGINT,
NumberOfSubmissions BIGINT,
NumberOfSubreddits BIGINT
);
-- Table: comments
DROP TABLE IF EXISTS comments;
CREATE TABLE comments (
InternalID BIGINT,
FetchedTime DATETIME,
RedditorID VARCHAR (25),
CommentBody TEXT,
CreationTime DATETIME,
Distunguished VARCHAR (25),
Edited BOOLEAN,
CommentID VARCHAR (25),
IsSubmitter BOOLEAN,
LinkID VARCHAR (25),
ParentID VARCHAR (25),
Permalink TEXT,
Score INTEGER,
Stickied BOOLEAN,
SubredditID VARCHAR (25),
PRIMARY KEY (
CommentID ASC
)
ON CONFLICT REPLACE,
UNIQUE (
InternalID ASC
)
ON CONFLICT IGNORE
);
-- Table: Downloads
DROP TABLE IF EXISTS Downloads;
CREATE TABLE Downloads (
SubredditID VARCHAR (25),
SubmissionID VARCHAR (25),
LastDownloadAttempted DATETIME,
LastDownloadCompleted DATETIME,
DownloadStatus VARCHAR (80) DEFAULT Never,
DownloadAttemptCount INTEGER DEFAULT (0),
LinkControl VARCHAR (250),
ServerReply TEXT,
LocalAbsoluteFilePath TEXT,
PRIMARY KEY (
SubredditID ASC,
SubmissionID
),
UNIQUE (
SubredditID,
SubmissionID
)
ON CONFLICT IGNORE
);
-- Table: redditor
DROP TABLE IF EXISTS redditor;
CREATE TABLE redditor (
RedditorID VARCHAR (25),
RedditorName VARCHAR (50),
CreationTime DATETIME,
VerifiedEmail BOOLEAN,
IsEmployee BOOLEAN,
IsFriend BOOLEAN
);
-- Table: submissions
DROP TABLE IF EXISTS submissions;
CREATE TABLE submissions (
InternalID BIGINT,
FetchedTime DATETIME,
DownloadStatus INTEGER,
DownloadCount INTEGER,
RedditorID VARCHAR (25),
CreationTime DATETIME,
Distunguished VARCHAR (25),
Edited BOOLEAN,
SubmissionID VARCHAR (25),
PostLocked BOOLEAN,
NSFW BOOLEAN,
Permalink TEXT,
Score INTEGER,
SelfText TEXT,
Stickied BOOLEAN,
SubredditID VARCHAR (25),
SubmissionTitle TEXT,
UpvoteRatio NUMBER,
URL TEXT,
PRIMARY KEY (
SubmissionID
)
ON CONFLICT IGNORE
);
-- Table: subreddits
DROP TABLE IF EXISTS subreddits;
CREATE TABLE subreddits (
SubredditName VARCHAR (150),
SubredditID VARCHAR (25),
CreationTime DATETIME,
NSFW BOOLEAN,
Description TEXT,
DescriptionHTML TEXT,
PublicDescription TEXT,
Rules TEXT,
DownloadStatus INTEGER,
DownloadCount INTEGER,
LastDownloadTime DATETIME,
PRIMARY KEY (
SubredditID
)
ON CONFLICT IGNORE
);
-- Index: SubmissionIDIndex
DROP INDEX IF EXISTS SubmissionIDIndex;
CREATE INDEX SubmissionIDIndex ON submissions (
SubmissionID
);
-- Index: SubmissionSubredditIDIndex
DROP INDEX IF EXISTS SubmissionSubredditIDIndex;
CREATE INDEX SubmissionSubredditIDIndex ON submissions (
SubredditID
);
COMMIT TRANSACTION;
PRAGMA foreign_keys = on;