-
Notifications
You must be signed in to change notification settings - Fork 1
/
tables-postgresql.sql
301 lines (243 loc) · 7.21 KB
/
tables-postgresql.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
-- Semantic Scuttle - Tables creation SQL script
-- ! Dont forget to change table names according to $tableprefix defined in config.php !
DROP TABLE IF EXISTS sc_bookmarks2tags;
DROP TABLE IF EXISTS sc_commondescription;
DROP TABLE IF EXISTS sc_searchhistory;
DROP TABLE IF EXISTS sc_tags;
DROP TABLE IF EXISTS sc_tags2tags;
DROP TABLE IF EXISTS sc_tagscache;
DROP TABLE IF EXISTS sc_tagsstats;
DROP TABLE IF EXISTS sc_users_sslclientcerts;
DROP TABLE IF EXISTS sc_version;
DROP TABLE IF EXISTS sc_votes;
DROP TABLE IF EXISTS sc_watched;
DROP TABLE IF EXISTS sc_bookmarks;
DROP TABLE IF EXISTS sc_users;
DROP SEQUENCE IF EXISTS bIds;
DROP SEQUENCE IF EXISTS b2tIds;
DROP SEQUENCE IF EXISTS cdIds;
DROP SEQUENCE IF EXISTS shIds;
DROP SEQUENCE IF EXISTS tIds;
DROP SEQUENCE IF EXISTS ttIds;
DROP SEQUENCE IF EXISTS tcIds;
DROP SEQUENCE IF EXISTS tstIds;
DROP SEQUENCE IF EXISTS uIds;
DROP SEQUENCE IF EXISTS ids;
DROP SEQUENCE IF EXISTS vIds;
DROP SEQUENCE IF EXISTS wIds;
--
-- Table structure for table "sc_users"
--
CREATE SEQUENCE uIds
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE sc_users (
uId integer DEFAULT nextval('uIds'::text) PRIMARY KEY,
username varchar(25) NOT NULL DEFAULT '',
password varchar(40) DEFAULT '',
uDatetime timestamp with time zone DEFAULT now(),
uModified timestamp with time zone DEFAULT now(),
name varchar(50) DEFAULT NULL,
email varchar(50) DEFAULT NULL,
homepage varchar(255) DEFAULT NULL,
uContent text,
privateKey varchar(33) DEFAULT NULL
);
CREATE UNIQUE INDEX privateKey on sc_users (privateKey);
--
-- Table structure for table "sc_tags"
--
CREATE SEQUENCE tIds
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE sc_tags (
tId integer DEFAULT nextval('tIds'::text) PRIMARY KEY,
tag varchar(100) NOT NULL DEFAULT '',
uId integer REFERENCES sc_users (uId),
tDescription text
);
--
-- Table structure for table "sc_bookmarks"
--
CREATE SEQUENCE bIds
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE sc_bookmarks (
bId integer DEFAULT nextval('bIds'::text) PRIMARY KEY,
uId integer REFERENCES sc_users (uId),
bIp varchar(40) DEFAULT NULL,
bStatus smallint NOT NULL,
bDatetime timestamp with time zone DEFAULT now(),
bModified timestamp with time zone DEFAULT now(),
bTitle varchar(255) DEFAULT '' NOT NULL,
bAddress varchar(1500) DEFAULT '' NOT NULL,
bDescription text,
bPrivateNote text,
bHash varchar(32) DEFAULT '' NOT NULL,
bVotes integer NOT NULL,
bVoting integer NOT NULL,
bShort varchar(16) DEFAULT NULL
);
CREATE INDEX sc_bookmarks_usd ON sc_bookmarks (uId, bStatus, bDatetime);
CREATE INDEX sc_bookmarks_hui ON sc_bookmarks (bHash, uId, bId);
CREATE INDEX sc_bookmarks_du ON sc_bookmarks (bDatetime, uId);
--
-- Table structure for table "sc_bookmarks2tags"
--
CREATE SEQUENCE b2tIds
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE sc_bookmarks2tags (
id integer DEFAULT nextval('b2tIds'::text) PRIMARY KEY,
bId integer REFERENCES sc_bookmarks(bId),
tId integer REFERENCES sc_tags(tId)
);
CREATE UNIQUE INDEX sc_bookmarks2tags_tag_bId on sc_bookmarks2tags (tId, bId);
CREATE INDEX sc_bookmarks2tags_bId on sc_bookmarks2tags (bId);
--
-- Table structure for table "sc_commondescription"
--
CREATE SEQUENCE cdIds
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE sc_commondescription (
cdId integer DEFAULT nextval('cdIds'::text) PRIMARY KEY,
uId integer REFERENCES sc_users (uId),
tag varchar(100) DEFAULT '' NOT NULL,
bHash varchar(32) DEFAULT '' NOT NULL,
cdTitle varchar(255) DEFAULT '' NOT NULL,
cdDescription text,
cdDatetime timestamp with time zone DEFAULT now() NOT NULL
);
CREATE UNIQUE INDEX sc_commondescription_tag_timestamp on sc_commondescription (tag, cdDatetime);
CREATE UNIQUE INDEX sc_commondescription_bookmark_timestamp on sc_commondescription (bHash, cdDatetime);
--
-- Table structure for table "sc_searchhistory"
--
CREATE SEQUENCE shIds
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE sc_searchhistory (
shId integer DEFAULT nextval('shIds'::text) PRIMARY KEY,
shTerms varchar(255) NOT NULL DEFAULT '',
shRange varchar(32) NOT NULL DEFAULT '',
shDatetime timestamp with time zone DEFAULT now() NOT NULL,
shNbResults integer NOT NULL,
uId integer REFERENCES sc_users (uId)
);
CREATE UNIQUE INDEX sc_tags_tag_uId on sc_tags (tag, uId);
--
-- Table structure for table "sc_tags2tags"
--
CREATE SEQUENCE ttIds
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE sc_tags2tags (
ttId integer DEFAULT nextval('ttIds'::text) PRIMARY KEY,
tag1 varchar(100) NOT NULL DEFAULT '',
tag2 varchar(100) NOT NULL DEFAULT '',
relationType varchar(32) NOT NULL DEFAULT '',
uId integer REFERENCES sc_users (uId)
);
CREATE UNIQUE INDEX sc_tags2tags_tag1_tag2_uId on sc_tags2tags (tag1, tag2, relationType, uId);
--
-- Table structure for table "sc_tagscache"
--
CREATE SEQUENCE tcIds
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE sc_tagscache (
tcId integer DEFAULT nextval('tcIds'::text) PRIMARY KEY,
tag1 varchar(100) NOT NULL DEFAULT '',
tag2 varchar(100) NOT NULL DEFAULT '',
relationType varchar(32) NOT NULL DEFAULT '',
uId integer NOT NULL DEFAULT '0'
);
CREATE UNIQUE INDEX sc_tagscache_tag1_tag2_type_uId on sc_tagscache (tag1, tag2, relationType, uId);
--
-- Table structure for table "sc_tagsstats"
--
CREATE SEQUENCE tstIds
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE sc_tagsstats (
tstId integer DEFAULT nextval('tstIds'::text) PRIMARY KEY,
tag1 varchar(100) NOT NULL DEFAULT '',
relationType varchar(32) NOT NULL DEFAULT '',
uId integer REFERENCES sc_users (uId),
nb integer NOT NULL,
depth integer NOT NULL,
nbupdate integer NOT NULL
);
CREATE UNIQUE INDEX sc_tagsstats_tag1_type_uId on sc_tagsstats (tag1, relationType, uId);
--
-- Table structure for table "sc_users_sslclientcerts"
--
CREATE SEQUENCE ids
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE sc_users_sslclientcerts (
id integer DEFAULT nextval('ids'::text) PRIMARY KEY,
uId integer REFERENCES sc_users (uId),
sslSerial varchar(32) DEFAULT '' NOT NULL,
sslClientIssuerDn varchar(1024) DEFAULT '' NOT NULL,
sslName varchar(64) DEFAULT '' NOT NULL,
sslEmail varchar(64) DEFAULT '' NOT NULL
);
--
-- Table structure for table "sc_version"
--
CREATE TABLE sc_version (
schema_version integer NOT NULL
);
--
-- Table structure for table "sc_votes"
--
CREATE SEQUENCE vIds
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE sc_votes (
id integer DEFAULT nextval('vIds'::text) PRIMARY KEY,
bId integer REFERENCES sc_bookmarks (bId),
uId integer REFERENCES sc_users (uId),
vote integer NOT NULL
);
CREATE UNIQUE INDEX bid_2 on sc_votes (bId, uId);
CREATE INDEX bid on sc_votes (bId);
CREATE INDEX uid on sc_votes (uId);
--
-- Table structure for table "sc_watched"
--
CREATE SEQUENCE wIds
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE sc_watched (
wId integer DEFAULT nextval('wIds'::text) PRIMARY KEY,
uId integer REFERENCES sc_users (uId),
watched integer NOT NULL
);
CREATE INDEX sc_watched_uId on sc_watched (uId);