forked from LibrariesHacked/openlibrary-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openlibrary-db.sql
305 lines (226 loc) · 5.38 KB
/
openlibrary-db.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
302
303
304
-- Database: openlibrary
-- DROP DATABASE openlibrary;
CREATE DATABASE openlibrary
WITH OWNER = postgres
ENCODING = 'UTF8'
TABLESPACE = pg_default
LC_COLLATE = 'English_United Kingdom.1252'
LC_CTYPE = 'English_United Kingdom.1252'
CONNECTION LIMIT = -1;
-- Table: public.authors
-- DROP TABLE public.authors;
CREATE TABLE public.authors
(
type text,
key text NOT NULL,
revision integer,
last_modified date,
data jsonb,
CONSTRAINT pk_author PRIMARY KEY (key)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.authors
OWNER TO postgres;
-- Index: public.cuix_author
-- DROP INDEX public.cuix_author;
CREATE UNIQUE INDEX cuix_author
ON public.authors
USING btree
(key COLLATE pg_catalog."default");
ALTER TABLE public.authors CLUSTER ON cuix_author;
-- Index: public.idx_authors_ginp
-- DROP INDEX public.idx_authors_ginp;
CREATE INDEX idx_authors_ginp
ON public.authors
USING gin
(data jsonb_path_ops);
-- Table: public.authorship
-- DROP TABLE public.authorship;
CREATE TABLE public.authorship
(
author_key text NOT NULL,
work_key text NOT NULL,
CONSTRAINT pk_authorship PRIMARY KEY (author_key, work_key)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.authorship
OWNER TO postgres;
-- Index: public.cuix_author_work
-- DROP INDEX public.cuix_author_work;
CREATE UNIQUE INDEX cuix_author_work
ON public.authorship
USING btree
(author_key COLLATE pg_catalog."default", work_key COLLATE pg_catalog."default");
ALTER TABLE public.authorship CLUSTER ON cuix_author_work;
-- Index: public.ix_work
-- DROP INDEX public.ix_work;
CREATE INDEX ix_work
ON public.authorship
USING btree
(work_key COLLATE pg_catalog."default");
-- Table: public.editionisbn10s
-- DROP TABLE public.editionisbn10s;
CREATE TABLE public.editionisbn10s
(
edition_key text NOT NULL,
isbn10 text NOT NULL,
CONSTRAINT pk_edition_isbn10 PRIMARY KEY (edition_key, isbn10)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.editionisbn10s
OWNER TO postgres;
-- Index: public.cix_edition_isbn10
-- DROP INDEX public.cix_edition_isbn10;
CREATE INDEX cix_edition_isbn10
ON public.editionisbn10s
USING btree
(edition_key COLLATE pg_catalog."default", isbn10 COLLATE pg_catalog."default");
ALTER TABLE public.editionisbn10s CLUSTER ON cix_edition_isbn10;
-- Index: public.ix_isbn10
-- DROP INDEX public.ix_isbn10;
CREATE INDEX ix_isbn10
ON public.editionisbn10s
USING btree
(isbn10 COLLATE pg_catalog."default");
-- Table: public.editionisbn13s
-- DROP TABLE public.editionisbn13s;
CREATE TABLE public.editionisbn13s
(
edition_key text,
isbn13 text
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.editionisbn13s
OWNER TO postgres;
-- Index: public.cuix_edition_isbn13
-- DROP INDEX public.cuix_edition_isbn13;
CREATE UNIQUE INDEX cuix_edition_isbn13
ON public.editionisbn13s
USING btree
(edition_key COLLATE pg_catalog."default", isbn13 COLLATE pg_catalog."default");
ALTER TABLE public.editionisbn13s CLUSTER ON cuix_edition_isbn13;
-- Index: public.ix_isbn13
-- DROP INDEX public.ix_isbn13;
CREATE INDEX ix_isbn13
ON public.editionisbn13s
USING btree
(isbn13 COLLATE pg_catalog."default");
-- Table: public.editions
-- DROP TABLE public.editions;
CREATE TABLE public.editions
(
type text,
key text NOT NULL,
revision integer,
last_modified date,
data jsonb,
work_key text,
CONSTRAINT pk_edition PRIMARY KEY (key)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.editions
OWNER TO postgres;
-- Table: public.isbn10s
-- DROP TABLE public.isbn10s;
CREATE TABLE public.isbn10s
(
isbn10 text
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.isbn10s
OWNER TO postgres;
-- Index: public.cix_isbn10
-- DROP INDEX public.cix_isbn10;
CREATE INDEX cix_isbn10
ON public.isbn10s
USING btree
(isbn10 COLLATE pg_catalog."default");
ALTER TABLE public.isbn10s CLUSTER ON cix_isbn10;
-- Table: public.isbn13s
-- DROP TABLE public.isbn13s;
CREATE TABLE public.isbn13s
(
isbn13 text
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.isbn13s
OWNER TO postgres;
-- Index: public.cix_isbn13
-- DROP INDEX public.cix_isbn13;
CREATE INDEX cix_isbn13
ON public.isbn13s
USING btree
(isbn13 COLLATE pg_catalog."default");
ALTER TABLE public.isbn13s CLUSTER ON cix_isbn13;
-- Table: public.keywords
-- DROP TABLE public.keywords;
CREATE TABLE public.keywords
(
keyword text NOT NULL,
CONSTRAINT keywords_pkey PRIMARY KEY (keyword)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.keywords
OWNER TO postgres;
-- Table: public.matches
-- DROP TABLE public.matches;
CREATE TABLE public.matches
(
title text,
subtitle text,
isbn10 text NOT NULL,
isbn13 text NOT NULL,
subjects text,
description text,
CONSTRAINT matches_pkey PRIMARY KEY (isbn10, isbn13)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.matches
OWNER TO postgres;
-- Table: public.works
-- DROP TABLE public.works;
CREATE TABLE public.works
(
type text,
key text NOT NULL,
revision integer,
last_modified date,
data jsonb,
CONSTRAINT pk_work PRIMARY KEY (key)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.works
OWNER TO postgres;
-- Index: public.cuix_work
-- DROP INDEX public.cuix_work;
CREATE UNIQUE INDEX cuix_work
ON public.works
USING btree
(key COLLATE pg_catalog."default");
ALTER TABLE public.works CLUSTER ON cuix_work;
-- Index: public.idx_works_ginp
-- DROP INDEX public.idx_works_ginp;
CREATE INDEX idx_works_ginp
ON public.works
USING gin
(data jsonb_path_ops);