· 8 years ago · Feb 05, 2018, 11:50 PM
1--
2-- PostgreSQL database dump
3--
4
5-- Dumped from database version 9.6.6
6-- Dumped by pg_dump version 9.6.6
7
8SET statement_timeout = 0;
9SET lock_timeout = 0;
10SET idle_in_transaction_session_timeout = 0;
11SET client_encoding = 'UTF8';
12SET standard_conforming_strings = on;
13SET check_function_bodies = false;
14SET client_min_messages = warning;
15SET row_security = off;
16
17--
18-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
19--
20
21CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
22
23
24--
25-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
26--
27
28COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
29
30
31SET search_path = public, pg_catalog;
32
33SET default_tablespace = '';
34
35SET default_with_oids = false;
36
37--
38-- Name: card; Type: TABLE; Schema: public; Owner: postgres
39--
40
41CREATE TABLE card (
42 id integer NOT NULL,
43 author_id integer NOT NULL,
44 name character varying(20) NOT NULL,
45 question character varying NOT NULL,
46 answer character varying NOT NULL,
47 img_src character varying
48);
49
50
51ALTER TABLE card OWNER TO postgres;
52
53--
54-- Name: card_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
55--
56
57CREATE SEQUENCE card_id_seq
58 START WITH 1
59 INCREMENT BY 1
60 NO MINVALUE
61 NO MAXVALUE
62 CACHE 1;
63
64
65ALTER TABLE card_id_seq OWNER TO postgres;
66
67--
68-- Name: card_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
69--
70
71ALTER SEQUENCE card_id_seq OWNED BY card.id;
72
73
74--
75-- Name: cardcollection; Type: TABLE; Schema: public; Owner: postgres
76--
77
78CREATE TABLE cardcollection (
79 card_id integer NOT NULL,
80 collection_id integer NOT NULL
81);
82
83
84ALTER TABLE cardcollection OWNER TO postgres;
85
86--
87-- Name: cardtag; Type: TABLE; Schema: public; Owner: postgres
88--
89
90CREATE TABLE cardtag (
91 card_id integer NOT NULL,
92 tag_id integer NOT NULL
93);
94
95
96ALTER TABLE cardtag OWNER TO postgres;
97
98--
99-- Name: collection; Type: TABLE; Schema: public; Owner: postgres
100--
101
102CREATE TABLE collection (
103 id integer NOT NULL,
104 author_id integer NOT NULL,
105 name character varying(20) NOT NULL
106);
107
108
109ALTER TABLE collection OWNER TO postgres;
110
111--
112-- Name: collection_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
113--
114
115CREATE SEQUENCE collection_id_seq
116 START WITH 1
117 INCREMENT BY 1
118 NO MINVALUE
119 NO MAXVALUE
120 CACHE 1;
121
122
123ALTER TABLE collection_id_seq OWNER TO postgres;
124
125--
126-- Name: collection_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
127--
128
129ALTER SEQUENCE collection_id_seq OWNED BY collection.id;
130
131
132--
133-- Name: collectiontag; Type: TABLE; Schema: public; Owner: postgres
134--
135
136CREATE TABLE collectiontag (
137 collection_id integer NOT NULL,
138 tag_id integer NOT NULL
139);
140
141
142ALTER TABLE collectiontag OWNER TO postgres;
143
144--
145-- Name: tag; Type: TABLE; Schema: public; Owner: postgres
146--
147
148CREATE TABLE tag (
149 id integer NOT NULL,
150 name character varying(100) NOT NULL
151);
152
153
154ALTER TABLE tag OWNER TO postgres;
155
156--
157-- Name: tag_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
158--
159
160CREATE SEQUENCE tag_id_seq
161 START WITH 1
162 INCREMENT BY 1
163 NO MINVALUE
164 NO MAXVALUE
165 CACHE 1;
166
167
168ALTER TABLE tag_id_seq OWNER TO postgres;
169
170--
171-- Name: tag_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
172--
173
174ALTER SEQUENCE tag_id_seq OWNED BY tag.id;
175
176
177--
178-- Name: test; Type: TABLE; Schema: public; Owner: postgres
179--
180
181CREATE TABLE test (
182 id integer NOT NULL,
183 user_id integer NOT NULL,
184 collection_id integer NOT NULL,
185 start_date timestamp with time zone DEFAULT timezone('UTC'::text, now()) NOT NULL,
186 end_date timestamp with time zone DEFAULT timezone('UTC'::text, now()) NOT NULL
187);
188
189
190ALTER TABLE test OWNER TO postgres;
191
192--
193-- Name: test_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
194--
195
196CREATE SEQUENCE test_id_seq
197 START WITH 1
198 INCREMENT BY 1
199 NO MINVALUE
200 NO MAXVALUE
201 CACHE 1;
202
203
204ALTER TABLE test_id_seq OWNER TO postgres;
205
206--
207-- Name: test_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
208--
209
210ALTER SEQUENCE test_id_seq OWNED BY test.id;
211
212
213--
214-- Name: testquestionresult; Type: TABLE; Schema: public; Owner: postgres
215--
216
217CREATE TABLE testquestionresult (
218 id integer NOT NULL,
219 test_id integer,
220 card_id integer NOT NULL,
221 answer character varying,
222 was_correct boolean
223);
224
225
226ALTER TABLE testquestionresult OWNER TO postgres;
227
228--
229-- Name: testquestionresult_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
230--
231
232CREATE SEQUENCE testquestionresult_id_seq
233 START WITH 1
234 INCREMENT BY 1
235 NO MINVALUE
236 NO MAXVALUE
237 CACHE 1;
238
239
240ALTER TABLE testquestionresult_id_seq OWNER TO postgres;
241
242--
243-- Name: testquestionresult_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
244--
245
246ALTER SEQUENCE testquestionresult_id_seq OWNED BY testquestionresult.id;
247
248
249--
250-- Name: useraccount; Type: TABLE; Schema: public; Owner: postgres
251--
252
253CREATE TABLE useraccount (
254 id integer NOT NULL,
255 username character varying(20) NOT NULL,
256 email character varying(100) NOT NULL,
257 password character varying NOT NULL
258);
259
260
261ALTER TABLE useraccount OWNER TO postgres;
262
263--
264-- Name: useraccount_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
265--
266
267CREATE SEQUENCE useraccount_id_seq
268 START WITH 1
269 INCREMENT BY 1
270 NO MINVALUE
271 NO MAXVALUE
272 CACHE 1;
273
274
275ALTER TABLE useraccount_id_seq OWNER TO postgres;
276
277--
278-- Name: useraccount_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
279--
280
281ALTER SEQUENCE useraccount_id_seq OWNED BY useraccount.id;
282
283
284--
285-- Name: card id; Type: DEFAULT; Schema: public; Owner: postgres
286--
287
288ALTER TABLE ONLY card ALTER COLUMN id SET DEFAULT nextval('card_id_seq'::regclass);
289
290
291--
292-- Name: collection id; Type: DEFAULT; Schema: public; Owner: postgres
293--
294
295ALTER TABLE ONLY collection ALTER COLUMN id SET DEFAULT nextval('collection_id_seq'::regclass);
296
297
298--
299-- Name: tag id; Type: DEFAULT; Schema: public; Owner: postgres
300--
301
302ALTER TABLE ONLY tag ALTER COLUMN id SET DEFAULT nextval('tag_id_seq'::regclass);
303
304
305--
306-- Name: test id; Type: DEFAULT; Schema: public; Owner: postgres
307--
308
309ALTER TABLE ONLY test ALTER COLUMN id SET DEFAULT nextval('test_id_seq'::regclass);
310
311
312--
313-- Name: testquestionresult id; Type: DEFAULT; Schema: public; Owner: postgres
314--
315
316ALTER TABLE ONLY testquestionresult ALTER COLUMN id SET DEFAULT nextval('testquestionresult_id_seq'::regclass);
317
318
319--
320-- Name: useraccount id; Type: DEFAULT; Schema: public; Owner: postgres
321--
322
323ALTER TABLE ONLY useraccount ALTER COLUMN id SET DEFAULT nextval('useraccount_id_seq'::regclass);
324
325
326--
327-- Data for Name: card; Type: TABLE DATA; Schema: public; Owner: postgres
328--
329
330COPY card (id, author_id, name, question, answer, img_src) FROM stdin;
331\.
332
333
334--
335-- Name: card_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
336--
337
338SELECT pg_catalog.setval('card_id_seq', 1, false);
339
340
341--
342-- Data for Name: cardcollection; Type: TABLE DATA; Schema: public; Owner: postgres
343--
344
345COPY cardcollection (card_id, collection_id) FROM stdin;
346\.
347
348
349--
350-- Data for Name: cardtag; Type: TABLE DATA; Schema: public; Owner: postgres
351--
352
353COPY cardtag (card_id, tag_id) FROM stdin;
354\.
355
356
357--
358-- Data for Name: collection; Type: TABLE DATA; Schema: public; Owner: postgres
359--
360
361COPY collection (id, author_id, name) FROM stdin;
362\.
363
364
365--
366-- Name: collection_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
367--
368
369SELECT pg_catalog.setval('collection_id_seq', 1, false);
370
371
372--
373-- Data for Name: collectiontag; Type: TABLE DATA; Schema: public; Owner: postgres
374--
375
376COPY collectiontag (collection_id, tag_id) FROM stdin;
377\.
378
379
380--
381-- Data for Name: tag; Type: TABLE DATA; Schema: public; Owner: postgres
382--
383
384COPY tag (id, name) FROM stdin;
385\.
386
387
388--
389-- Name: tag_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
390--
391
392SELECT pg_catalog.setval('tag_id_seq', 1, false);
393
394
395--
396-- Data for Name: test; Type: TABLE DATA; Schema: public; Owner: postgres
397--
398
399COPY test (id, user_id, collection_id, start_date, end_date) FROM stdin;
400\.
401
402
403--
404-- Name: test_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
405--
406
407SELECT pg_catalog.setval('test_id_seq', 1, false);
408
409
410--
411-- Data for Name: testquestionresult; Type: TABLE DATA; Schema: public; Owner: postgres
412--
413
414COPY testquestionresult (id, test_id, card_id, answer, was_correct) FROM stdin;
415\.
416
417
418--
419-- Name: testquestionresult_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
420--
421
422SELECT pg_catalog.setval('testquestionresult_id_seq', 1, false);
423
424
425--
426-- Data for Name: useraccount; Type: TABLE DATA; Schema: public; Owner: postgres
427--
428
429COPY useraccount (id, username, email, password) FROM stdin;
430\.
431
432
433--
434-- Name: useraccount_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
435--
436
437SELECT pg_catalog.setval('useraccount_id_seq', 1, false);
438
439
440--
441-- Name: card card_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
442--
443
444ALTER TABLE ONLY card
445 ADD CONSTRAINT card_pkey PRIMARY KEY (id);
446
447
448--
449-- Name: collection collection_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
450--
451
452ALTER TABLE ONLY collection
453 ADD CONSTRAINT collection_pkey PRIMARY KEY (id);
454
455
456--
457-- Name: tag tag_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
458--
459
460ALTER TABLE ONLY tag
461 ADD CONSTRAINT tag_pkey PRIMARY KEY (id);
462
463
464--
465-- Name: test test_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
466--
467
468ALTER TABLE ONLY test
469 ADD CONSTRAINT test_pkey PRIMARY KEY (id);
470
471
472--
473-- Name: testquestionresult testquestionresult_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
474--
475
476ALTER TABLE ONLY testquestionresult
477 ADD CONSTRAINT testquestionresult_pkey PRIMARY KEY (id);
478
479
480--
481-- Name: useraccount useraccount_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
482--
483
484ALTER TABLE ONLY useraccount
485 ADD CONSTRAINT useraccount_pkey PRIMARY KEY (id);
486
487
488--
489-- Name: card card_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
490--
491
492ALTER TABLE ONLY card
493 ADD CONSTRAINT card_author_id_fkey FOREIGN KEY (author_id) REFERENCES useraccount(id) ON UPDATE CASCADE ON DELETE SET NULL;
494
495
496--
497-- Name: cardcollection cardcollection_card_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
498--
499
500ALTER TABLE ONLY cardcollection
501 ADD CONSTRAINT cardcollection_card_id_fkey FOREIGN KEY (card_id) REFERENCES card(id) ON UPDATE CASCADE ON DELETE CASCADE;
502
503
504--
505-- Name: cardcollection cardcollection_collection_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
506--
507
508ALTER TABLE ONLY cardcollection
509 ADD CONSTRAINT cardcollection_collection_id_fkey FOREIGN KEY (collection_id) REFERENCES collection(id) ON UPDATE CASCADE ON DELETE CASCADE;
510
511
512--
513-- Name: cardtag cardtag_card_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
514--
515
516ALTER TABLE ONLY cardtag
517 ADD CONSTRAINT cardtag_card_id_fkey FOREIGN KEY (card_id) REFERENCES card(id) ON UPDATE CASCADE ON DELETE CASCADE;
518
519
520--
521-- Name: cardtag cardtag_tag_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
522--
523
524ALTER TABLE ONLY cardtag
525 ADD CONSTRAINT cardtag_tag_id_fkey FOREIGN KEY (tag_id) REFERENCES tag(id) ON UPDATE CASCADE ON DELETE CASCADE;
526
527
528--
529-- Name: collection collection_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
530--
531
532ALTER TABLE ONLY collection
533 ADD CONSTRAINT collection_author_id_fkey FOREIGN KEY (author_id) REFERENCES useraccount(id) ON UPDATE CASCADE ON DELETE SET NULL;
534
535
536--
537-- Name: collectiontag collectiontag_collection_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
538--
539
540ALTER TABLE ONLY collectiontag
541 ADD CONSTRAINT collectiontag_collection_id_fkey FOREIGN KEY (collection_id) REFERENCES collection(id) ON UPDATE CASCADE ON DELETE CASCADE;
542
543
544--
545-- Name: collectiontag collectiontag_tag_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
546--
547
548ALTER TABLE ONLY collectiontag
549 ADD CONSTRAINT collectiontag_tag_id_fkey FOREIGN KEY (tag_id) REFERENCES tag(id) ON UPDATE CASCADE ON DELETE CASCADE;
550
551
552--
553-- Name: test test_collection_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
554--
555
556ALTER TABLE ONLY test
557 ADD CONSTRAINT test_collection_id_fkey FOREIGN KEY (collection_id) REFERENCES collection(id) ON UPDATE CASCADE ON DELETE CASCADE;
558
559
560--
561-- Name: test test_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
562--
563
564ALTER TABLE ONLY test
565 ADD CONSTRAINT test_user_id_fkey FOREIGN KEY (user_id) REFERENCES useraccount(id) ON UPDATE CASCADE ON DELETE CASCADE;
566
567
568--
569-- Name: testquestionresult testquestionresult_card_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
570--
571
572ALTER TABLE ONLY testquestionresult
573 ADD CONSTRAINT testquestionresult_card_id_fkey FOREIGN KEY (card_id) REFERENCES card(id) ON UPDATE CASCADE ON DELETE CASCADE;
574
575
576--
577-- Name: testquestionresult testquestionresult_test_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
578--
579
580ALTER TABLE ONLY testquestionresult
581 ADD CONSTRAINT testquestionresult_test_id_fkey FOREIGN KEY (test_id) REFERENCES test(id) ON UPDATE CASCADE ON DELETE SET NULL;
582
583
584--
585-- PostgreSQL database dump complete
586--