-
Notifications
You must be signed in to change notification settings - Fork 0
/
t_shirt.sql
319 lines (228 loc) · 8.17 KB
/
t_shirt.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
311
312
313
314
315
316
317
318
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.6.13
-- Dumped by pg_dump version 9.6.13
-- Started on 2020-05-10 23:15:15
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- TOC entry 1 (class 3079 OID 12387)
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- TOC entry 2167 (class 0 OID 0)
-- Dependencies: 1
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
--
-- TOC entry 187 (class 1259 OID 263137)
-- Name: order_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.order_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.order_id_seq OWNER TO postgres;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 190 (class 1259 OID 263163)
-- Name: orders; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.orders (
id integer DEFAULT nextval('public.order_id_seq'::regclass) NOT NULL,
create_date date NOT NULL
);
ALTER TABLE public.orders OWNER TO postgres;
--
-- TOC entry 188 (class 1259 OID 263141)
-- Name: stock_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.stock_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.stock_id_seq OWNER TO postgres;
--
-- TOC entry 186 (class 1259 OID 263132)
-- Name: stock; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.stock (
id integer DEFAULT nextval('public.stock_id_seq'::regclass) NOT NULL,
item_number integer NOT NULL,
t_shirt_id integer NOT NULL
);
ALTER TABLE public.stock OWNER TO postgres;
--
-- TOC entry 189 (class 1259 OID 263143)
-- Name: t_shirt_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.t_shirt_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.t_shirt_id_seq OWNER TO postgres;
--
-- TOC entry 192 (class 1259 OID 263173)
-- Name: t_shirt_order_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.t_shirt_order_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.t_shirt_order_id_seq OWNER TO postgres;
--
-- TOC entry 191 (class 1259 OID 263168)
-- Name: t_shirt_order; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.t_shirt_order (
id integer DEFAULT nextval('public.t_shirt_order_id_seq'::regclass) NOT NULL,
name character varying(100) NOT NULL,
age integer NOT NULL,
t_shirt_id integer NOT NULL,
order_id integer NOT NULL
);
ALTER TABLE public.t_shirt_order OWNER TO postgres;
--
-- TOC entry 185 (class 1259 OID 263114)
-- Name: t_shirts; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.t_shirts (
id integer DEFAULT nextval('public.t_shirt_id_seq'::regclass) NOT NULL,
color text NOT NULL,
size text NOT NULL
);
ALTER TABLE public.t_shirts OWNER TO postgres;
--
-- TOC entry 2168 (class 0 OID 0)
-- Dependencies: 187
-- Name: order_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.order_id_seq', 7, true);
--
-- TOC entry 2157 (class 0 OID 263163)
-- Dependencies: 190
-- Data for Name: orders; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2153 (class 0 OID 263132)
-- Dependencies: 186
-- Data for Name: stock; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO public.stock (id, item_number, t_shirt_id) VALUES (1, 14, 1);
INSERT INTO public.stock (id, item_number, t_shirt_id) VALUES (2, 23, 2);
INSERT INTO public.stock (id, item_number, t_shirt_id) VALUES (3, 21, 3);
INSERT INTO public.stock (id, item_number, t_shirt_id) VALUES (4, 7, 4);
INSERT INTO public.stock (id, item_number, t_shirt_id) VALUES (5, 16, 5);
INSERT INTO public.stock (id, item_number, t_shirt_id) VALUES (6, 20, 6);
INSERT INTO public.stock (id, item_number, t_shirt_id) VALUES (7, 18, 7);
INSERT INTO public.stock (id, item_number, t_shirt_id) VALUES (8, 8, 8);
INSERT INTO public.stock (id, item_number, t_shirt_id) VALUES (9, 12, 9);
INSERT INTO public.stock (id, item_number, t_shirt_id) VALUES (10, 16, 10);
INSERT INTO public.stock (id, item_number, t_shirt_id) VALUES (11, 15, 11);
INSERT INTO public.stock (id, item_number, t_shirt_id) VALUES (12, 10, 12);
--
-- TOC entry 2169 (class 0 OID 0)
-- Dependencies: 188
-- Name: stock_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.stock_id_seq', 12, true);
--
-- TOC entry 2170 (class 0 OID 0)
-- Dependencies: 189
-- Name: t_shirt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.t_shirt_id_seq', 12, true);
--
-- TOC entry 2158 (class 0 OID 263168)
-- Dependencies: 191
-- Data for Name: t_shirt_order; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2171 (class 0 OID 0)
-- Dependencies: 192
-- Name: t_shirt_order_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.t_shirt_order_id_seq', 6, true);
--
-- TOC entry 2152 (class 0 OID 263114)
-- Dependencies: 185
-- Data for Name: t_shirts; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO public.t_shirts (id, color, size) VALUES (5, 'niebieski', 'S');
INSERT INTO public.t_shirts (id, color, size) VALUES (6, 'niebieski', 'M');
INSERT INTO public.t_shirts (id, color, size) VALUES (7, 'niebieski', 'L');
INSERT INTO public.t_shirts (id, color, size) VALUES (8, 'niebieski', 'XL');
INSERT INTO public.t_shirts (id, color, size) VALUES (9, 'zielony', 'M');
INSERT INTO public.t_shirts (id, color, size) VALUES (10, 'zielony', 'S');
INSERT INTO public.t_shirts (id, color, size) VALUES (11, 'zielony', 'L');
INSERT INTO public.t_shirts (id, color, size) VALUES (12, 'zielony', 'XL');
INSERT INTO public.t_shirts (id, color, size) VALUES (1, 'czerwony', 'S');
INSERT INTO public.t_shirts (id, color, size) VALUES (2, 'czerwony', 'M');
INSERT INTO public.t_shirts (id, color, size) VALUES (3, 'czerwony', 'L');
INSERT INTO public.t_shirts (id, color, size) VALUES (4, 'czerwony', 'XL');
--
-- TOC entry 2029 (class 2606 OID 263167)
-- Name: orders orders_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.orders
ADD CONSTRAINT orders_pkey PRIMARY KEY (id);
--
-- TOC entry 2027 (class 2606 OID 263136)
-- Name: stock stock_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.stock
ADD CONSTRAINT stock_pkey PRIMARY KEY (id);
--
-- TOC entry 2025 (class 2606 OID 263121)
-- Name: t_shirts t_shirt_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.t_shirts
ADD CONSTRAINT t_shirt_pkey PRIMARY KEY (id);
--
-- TOC entry 2031 (class 2606 OID 263172)
-- Name: t_shirt_order tshirt_order_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.t_shirt_order
ADD CONSTRAINT tshirt_order_pkey PRIMARY KEY (id);
--
-- TOC entry 2034 (class 2606 OID 263187)
-- Name: t_shirt_order order_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.t_shirt_order
ADD CONSTRAINT order_fk FOREIGN KEY (order_id) REFERENCES public.orders(id);
--
-- TOC entry 2032 (class 2606 OID 263158)
-- Name: stock t_shirt_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.stock
ADD CONSTRAINT t_shirt_fk FOREIGN KEY (t_shirt_id) REFERENCES public.t_shirts(id);
--
-- TOC entry 2033 (class 2606 OID 263182)
-- Name: t_shirt_order t_shirt_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.t_shirt_order
ADD CONSTRAINT t_shirt_fk FOREIGN KEY (t_shirt_id) REFERENCES public.t_shirts(id);
-- Completed on 2020-05-10 23:15:16
--
-- PostgreSQL database dump complete
--