-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdumpDataBaseBooks.sql
311 lines (212 loc) · 6.44 KB
/
dumpDataBaseBooks.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
305
306
307
308
309
310
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.5.6
-- Dumped by pg_dump version 9.5.6
-- Started on 2017-12-03 20:38:32
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
--
-- TOC entry 1 (class 3079 OID 12355)
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- TOC entry 2150 (class 0 OID 0)
-- Dependencies: 1
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 183 (class 1259 OID 25425)
-- Name: authors; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE authors (
id integer NOT NULL,
fio character varying(75)
);
ALTER TABLE authors OWNER TO postgres;
--
-- TOC entry 182 (class 1259 OID 25422)
-- Name: books; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE books (
id integer NOT NULL,
name character varying(25),
idauthor integer
);
ALTER TABLE books OWNER TO postgres;
--
-- TOC entry 186 (class 1259 OID 25474)
-- Name: country; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE country (
id integer NOT NULL,
name character varying(20)
);
ALTER TABLE country OWNER TO postgres;
--
-- TOC entry 185 (class 1259 OID 25455)
-- Name: recomendations; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE recomendations (
iduser integer,
idbook integer,
id integer NOT NULL
);
ALTER TABLE recomendations OWNER TO postgres;
--
-- TOC entry 181 (class 1259 OID 25407)
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE users (
id integer NOT NULL,
login character varying(15),
password character varying(8),
firstname character varying(35),
lastname character varying(35),
age integer,
mail character varying(35),
idcountry integer
);
ALTER TABLE users OWNER TO postgres;
--
-- TOC entry 2151 (class 0 OID 0)
-- Dependencies: 181
-- Name: COLUMN users.password; Type: COMMENT; Schema: public; Owner: postgres
--
COMMENT ON COLUMN users.password IS '
';
--
-- TOC entry 184 (class 1259 OID 25438)
-- Name: usertags; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE usertags (
iduser integer,
idbook integer,
id integer NOT NULL
);
ALTER TABLE usertags OWNER TO postgres;
--
-- TOC entry 2006 (class 2606 OID 25429)
-- Name: primKeyAuth; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY authors
ADD CONSTRAINT "primKeyAuth" PRIMARY KEY (id);
--
-- TOC entry 2004 (class 2606 OID 25431)
-- Name: primKeybook; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY books
ADD CONSTRAINT "primKeybook" PRIMARY KEY (id);
--
-- TOC entry 2014 (class 2606 OID 25461)
-- Name: primRec; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY recomendations
ADD CONSTRAINT "primRec" PRIMARY KEY (id);
--
-- TOC entry 2001 (class 2606 OID 25448)
-- Name: primUser; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY users
ADD CONSTRAINT "primUser" PRIMARY KEY (id);
--
-- TOC entry 2016 (class 2606 OID 25478)
-- Name: primcount; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY country
ADD CONSTRAINT primcount PRIMARY KEY (id);
--
-- TOC entry 2010 (class 2606 OID 25459)
-- Name: primtags; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY usertags
ADD CONSTRAINT primtags PRIMARY KEY (id);
--
-- TOC entry 2011 (class 1259 OID 25473)
-- Name: fki_forBokkRec; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "fki_forBokkRec" ON recomendations USING btree (idbook);
--
-- TOC entry 2007 (class 1259 OID 25446)
-- Name: fki_forBook; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "fki_forBook" ON usertags USING btree (idbook);
--
-- TOC entry 1999 (class 1259 OID 25484)
-- Name: fki_forCount; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "fki_forCount" ON users USING btree (idcountry);
--
-- TOC entry 2002 (class 1259 OID 25437)
-- Name: fki_forKeyBook; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "fki_forKeyBook" ON books USING btree (idauthor);
--
-- TOC entry 2008 (class 1259 OID 25454)
-- Name: fki_forUser; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "fki_forUser" ON usertags USING btree (iduser);
--
-- TOC entry 2012 (class 1259 OID 25467)
-- Name: fki_forUserRec; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "fki_forUserRec" ON recomendations USING btree (iduser);
--
-- TOC entry 2022 (class 2606 OID 25468)
-- Name: forBokkRec; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY recomendations
ADD CONSTRAINT "forBokkRec" FOREIGN KEY (idbook) REFERENCES books(id);
--
-- TOC entry 2019 (class 2606 OID 25441)
-- Name: forBook; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY usertags
ADD CONSTRAINT "forBook" FOREIGN KEY (idbook) REFERENCES books(id);
--
-- TOC entry 2017 (class 2606 OID 25479)
-- Name: forCount; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY users
ADD CONSTRAINT "forCount" FOREIGN KEY (idcountry) REFERENCES country(id);
--
-- TOC entry 2018 (class 2606 OID 25432)
-- Name: forKeyBook; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY books
ADD CONSTRAINT "forKeyBook" FOREIGN KEY (idauthor) REFERENCES authors(id);
--
-- TOC entry 2020 (class 2606 OID 25449)
-- Name: forUser; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY usertags
ADD CONSTRAINT "forUser" FOREIGN KEY (iduser) REFERENCES users(id);
--
-- TOC entry 2021 (class 2606 OID 25462)
-- Name: forUserRec; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY recomendations
ADD CONSTRAINT "forUserRec" FOREIGN KEY (iduser) REFERENCES users(id);
--
-- TOC entry 2149 (class 0 OID 0)
-- Dependencies: 6
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
-- Completed on 2017-12-03 20:38:33
--
-- PostgreSQL database dump complete
--