Advertisement
Guest User

Untitled

a guest
Sep 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --
  2. -- PostgreSQL database dump
  3. --
  4.  
  5. -- Dumped from database version 9.5.6
  6. -- Dumped by pg_dump version 9.5.6
  7.  
  8. -- Started on 2018-09-17 16:55:31
  9.  
  10. SET statement_timeout = 0;
  11. SET lock_timeout = 0;
  12. SET client_encoding = 'UTF8';
  13. SET standard_conforming_strings = on;
  14. SET check_function_bodies = false;
  15. SET client_min_messages = warning;
  16. SET row_security = off;
  17.  
  18. --
  19. -- TOC entry 1 (class 3079 OID 12355)
  20. -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
  21. --
  22.  
  23. CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
  24.  
  25.  
  26. --
  27. -- TOC entry 2169 (class 0 OID 0)
  28. -- Dependencies: 1
  29. -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
  30. --
  31.  
  32. COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
  33.  
  34.  
  35. SET search_path = public, pg_catalog;
  36.  
  37. --
  38. -- TOC entry 185 (class 1259 OID 50711)
  39. -- Name: basket_id_basket_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  40. --
  41.  
  42. CREATE SEQUENCE basket_id_basket_seq
  43.     START WITH 1
  44.     INCREMENT BY 1
  45.     NO MINVALUE
  46.     MAXVALUE 1000000000
  47.     CACHE 1;
  48.  
  49.  
  50. ALTER TABLE basket_id_basket_seq OWNER TO postgres;
  51.  
  52. SET default_tablespace = '';
  53.  
  54. SET default_with_oids = false;
  55.  
  56. --
  57. -- TOC entry 186 (class 1259 OID 50713)
  58. -- Name: basket; Type: TABLE; Schema: public; Owner: postgres
  59. --
  60.  
  61. CREATE TABLE basket (
  62.     basket_id integer DEFAULT nextval('basket_id_basket_seq'::regclass) NOT NULL,
  63.     user_id integer NOT NULL,
  64.     total_cost integer NOT NULL
  65. );
  66.  
  67.  
  68. ALTER TABLE basket OWNER TO postgres;
  69.  
  70. --
  71. -- TOC entry 183 (class 1259 OID 50703)
  72. -- Name: product_id_product_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  73. --
  74.  
  75. CREATE SEQUENCE product_id_product_seq
  76.     START WITH 1
  77.     INCREMENT BY 1
  78.     NO MINVALUE
  79.     MAXVALUE 1000000000
  80.     CACHE 1;
  81.  
  82.  
  83. ALTER TABLE product_id_product_seq OWNER TO postgres;
  84.  
  85. --
  86. -- TOC entry 184 (class 1259 OID 50705)
  87. -- Name: product; Type: TABLE; Schema: public; Owner: postgres
  88. --
  89.  
  90. CREATE TABLE product (
  91.     product_id integer DEFAULT nextval('product_id_product_seq'::regclass) NOT NULL,
  92.     name character varying(50) NOT NULL,
  93.     cost integer NOT NULL,
  94.     category character varying(50) NOT NULL
  95. );
  96.  
  97.  
  98. ALTER TABLE product OWNER TO postgres;
  99.  
  100. --
  101. -- TOC entry 191 (class 1259 OID 75342)
  102. -- Name: product_to_basket_id_product_to_basket_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  103. --
  104.  
  105. CREATE SEQUENCE product_to_basket_id_product_to_basket_seq
  106.     START WITH 1
  107.     INCREMENT BY 1
  108.     NO MINVALUE
  109.     NO MAXVALUE
  110.     CACHE 1;
  111.  
  112.  
  113. ALTER TABLE product_to_basket_id_product_to_basket_seq OWNER TO postgres;
  114.  
  115. --
  116. -- TOC entry 192 (class 1259 OID 75347)
  117. -- Name: product_to_basket; Type: TABLE; Schema: public; Owner: postgres
  118. --
  119.  
  120. CREATE TABLE product_to_basket (
  121.     id_product_to_basket integer DEFAULT nextval('product_to_basket_id_product_to_basket_seq'::regclass) NOT NULL,
  122.     basket_id integer NOT NULL,
  123.     product_id integer NOT NULL
  124. );
  125.  
  126.  
  127. ALTER TABLE product_to_basket OWNER TO postgres;
  128.  
  129. --
  130. -- TOC entry 187 (class 1259 OID 50756)
  131. -- Name: role_id_role_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  132. --
  133.  
  134. CREATE SEQUENCE role_id_role_seq
  135.     START WITH 1
  136.     INCREMENT BY 1
  137.     NO MINVALUE
  138.     NO MAXVALUE
  139.     CACHE 1;
  140.  
  141.  
  142. ALTER TABLE role_id_role_seq OWNER TO postgres;
  143.  
  144. --
  145. -- TOC entry 188 (class 1259 OID 50758)
  146. -- Name: role; Type: TABLE; Schema: public; Owner: postgres
  147. --
  148.  
  149. CREATE TABLE role (
  150.     role_id integer DEFAULT nextval('role_id_role_seq'::regclass) NOT NULL,
  151.     role_name character varying(50) NOT NULL
  152. );
  153.  
  154.  
  155. ALTER TABLE role OWNER TO postgres;
  156.  
  157. --
  158. -- TOC entry 181 (class 1259 OID 50693)
  159. -- Name: user_account_id_user_account_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  160. --
  161.  
  162. CREATE SEQUENCE user_account_id_user_account_seq
  163.     START WITH 1
  164.     INCREMENT BY 1
  165.     NO MINVALUE
  166.     MAXVALUE 10000000
  167.     CACHE 1;
  168.  
  169.  
  170. ALTER TABLE user_account_id_user_account_seq OWNER TO postgres;
  171.  
  172. --
  173. -- TOC entry 182 (class 1259 OID 50695)
  174. -- Name: user_account; Type: TABLE; Schema: public; Owner: postgres
  175. --
  176.  
  177. CREATE TABLE user_account (
  178.     user_id integer DEFAULT nextval('user_account_id_user_account_seq'::regclass) NOT NULL,
  179.     name character varying(50) NOT NULL,
  180.     password character varying(50) NOT NULL,
  181.     email character varying(50) NOT NULL
  182. );
  183.  
  184.  
  185. ALTER TABLE user_account OWNER TO postgres;
  186.  
  187. --
  188. -- TOC entry 190 (class 1259 OID 50766)
  189. -- Name: user_account_to_role; Type: TABLE; Schema: public; Owner: postgres
  190. --
  191.  
  192. CREATE TABLE user_account_to_role (
  193.     id_user_to_roles integer NOT NULL,
  194.     user_id integer NOT NULL,
  195.     role_id integer NOT NULL
  196. );
  197.  
  198.  
  199. ALTER TABLE user_account_to_role OWNER TO postgres;
  200.  
  201. --
  202. -- TOC entry 189 (class 1259 OID 50764)
  203. -- Name: user_account_to_role_id_user_account_to_role_seq; Type: SEQUENCE; Schema: public; Owner: postgres
  204. --
  205.  
  206. CREATE SEQUENCE user_account_to_role_id_user_account_to_role_seq
  207.     START WITH 1
  208.     INCREMENT BY 1
  209.     NO MINVALUE
  210.     NO MAXVALUE
  211.     CACHE 1;
  212.  
  213.  
  214. ALTER TABLE user_account_to_role_id_user_account_to_role_seq OWNER TO postgres;
  215.  
  216. --
  217. -- TOC entry 2170 (class 0 OID 0)
  218. -- Dependencies: 189
  219. -- Name: user_account_to_role_id_user_account_to_role_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
  220. --
  221.  
  222. ALTER SEQUENCE user_account_to_role_id_user_account_to_role_seq OWNED BY user_account_to_role.id_user_to_roles;
  223.  
  224.  
  225. --
  226. -- TOC entry 2015 (class 2604 OID 50769)
  227. -- Name: id_user_to_roles; Type: DEFAULT; Schema: public; Owner: postgres
  228. --
  229.  
  230. ALTER TABLE ONLY user_account_to_role ALTER COLUMN id_user_to_roles SET DEFAULT nextval('user_account_to_role_id_user_account_to_role_seq'::regclass);
  231.  
  232.  
  233. --
  234. -- TOC entry 2155 (class 0 OID 50713)
  235. -- Dependencies: 186
  236. -- Data for Name: basket; Type: TABLE DATA; Schema: public; Owner: postgres
  237. --
  238.  
  239. COPY basket (basket_id, user_id, total_cost) FROM stdin;
  240. \.
  241.  
  242.  
  243. --
  244. -- TOC entry 2171 (class 0 OID 0)
  245. -- Dependencies: 185
  246. -- Name: basket_id_basket_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
  247. --
  248.  
  249. SELECT pg_catalog.setval('basket_id_basket_seq', 1, false);
  250.  
  251.  
  252. --
  253. -- TOC entry 2153 (class 0 OID 50705)
  254. -- Dependencies: 184
  255. -- Data for Name: product; Type: TABLE DATA; Schema: public; Owner: postgres
  256. --
  257.  
  258. COPY product (product_id, name, cost, category) FROM stdin;
  259. \.
  260.  
  261.  
  262. --
  263. -- TOC entry 2172 (class 0 OID 0)
  264. -- Dependencies: 183
  265. -- Name: product_id_product_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
  266. --
  267.  
  268. SELECT pg_catalog.setval('product_id_product_seq', 1, false);
  269.  
  270.  
  271. --
  272. -- TOC entry 2161 (class 0 OID 75347)
  273. -- Dependencies: 192
  274. -- Data for Name: product_to_basket; Type: TABLE DATA; Schema: public; Owner: postgres
  275. --
  276.  
  277. COPY product_to_basket (id_product_to_basket, basket_id, product_id) FROM stdin;
  278. \.
  279.  
  280.  
  281. --
  282. -- TOC entry 2173 (class 0 OID 0)
  283. -- Dependencies: 191
  284. -- Name: product_to_basket_id_product_to_basket_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
  285. --
  286.  
  287. SELECT pg_catalog.setval('product_to_basket_id_product_to_basket_seq', 1, false);
  288.  
  289.  
  290. --
  291. -- TOC entry 2157 (class 0 OID 50758)
  292. -- Dependencies: 188
  293. -- Data for Name: role; Type: TABLE DATA; Schema: public; Owner: postgres
  294. --
  295.  
  296. COPY role (role_id, role_name) FROM stdin;
  297. 1   USER
  298. \.
  299.  
  300.  
  301. --
  302. -- TOC entry 2174 (class 0 OID 0)
  303. -- Dependencies: 187
  304. -- Name: role_id_role_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
  305. --
  306.  
  307. SELECT pg_catalog.setval('role_id_role_seq', 1, true);
  308.  
  309.  
  310. --
  311. -- TOC entry 2151 (class 0 OID 50695)
  312. -- Dependencies: 182
  313. -- Data for Name: user_account; Type: TABLE DATA; Schema: public; Owner: postgres
  314. --
  315.  
  316. COPY user_account (user_id, name, password, email) FROM stdin;
  317. 4   userName    userPassword    userEmail
  318. \.
  319.  
  320.  
  321. --
  322. -- TOC entry 2175 (class 0 OID 0)
  323. -- Dependencies: 181
  324. -- Name: user_account_id_user_account_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
  325. --
  326.  
  327. SELECT pg_catalog.setval('user_account_id_user_account_seq', 4, true);
  328.  
  329.  
  330. --
  331. -- TOC entry 2159 (class 0 OID 50766)
  332. -- Dependencies: 190
  333. -- Data for Name: user_account_to_role; Type: TABLE DATA; Schema: public; Owner: postgres
  334. --
  335.  
  336. COPY user_account_to_role (id_user_to_roles, user_id, role_id) FROM stdin;
  337. 1   4   1
  338. \.
  339.  
  340.  
  341. --
  342. -- TOC entry 2176 (class 0 OID 0)
  343. -- Dependencies: 189
  344. -- Name: user_account_to_role_id_user_account_to_role_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
  345. --
  346.  
  347. SELECT pg_catalog.setval('user_account_to_role_id_user_account_to_role_seq', 1, true);
  348.  
  349.  
  350. --
  351. -- TOC entry 2024 (class 2606 OID 50718)
  352. -- Name: baskets_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  353. --
  354.  
  355. ALTER TABLE ONLY basket
  356.     ADD CONSTRAINT baskets_pkey PRIMARY KEY (basket_id);
  357.  
  358.  
  359. --
  360. -- TOC entry 2030 (class 2606 OID 75352)
  361. -- Name: product_to_basket_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  362. --
  363.  
  364. ALTER TABLE ONLY product_to_basket
  365.     ADD CONSTRAINT product_to_basket_pkey PRIMARY KEY (id_product_to_basket);
  366.  
  367.  
  368. --
  369. -- TOC entry 2022 (class 2606 OID 50710)
  370. -- Name: products_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  371. --
  372.  
  373. ALTER TABLE ONLY product
  374.     ADD CONSTRAINT products_pkey PRIMARY KEY (product_id);
  375.  
  376.  
  377. --
  378. -- TOC entry 2026 (class 2606 OID 50763)
  379. -- Name: roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  380. --
  381.  
  382. ALTER TABLE ONLY role
  383.     ADD CONSTRAINT roles_pkey PRIMARY KEY (role_id);
  384.  
  385.  
  386. --
  387. -- TOC entry 2018 (class 2606 OID 50702)
  388. -- Name: users_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres
  389. --
  390.  
  391. ALTER TABLE ONLY user_account
  392.     ADD CONSTRAINT users_email_key UNIQUE (email);
  393.  
  394.  
  395. --
  396. -- TOC entry 2020 (class 2606 OID 50700)
  397. -- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  398. --
  399.  
  400. ALTER TABLE ONLY user_account
  401.     ADD CONSTRAINT users_pkey PRIMARY KEY (user_id);
  402.  
  403.  
  404. --
  405. -- TOC entry 2028 (class 2606 OID 50771)
  406. -- Name: users_to_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
  407. --
  408.  
  409. ALTER TABLE ONLY user_account_to_role
  410.     ADD CONSTRAINT users_to_roles_pkey PRIMARY KEY (id_user_to_roles);
  411.  
  412.  
  413. --
  414. -- TOC entry 2035 (class 2606 OID 75358)
  415. -- Name: basket_to_product_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  416. --
  417.  
  418. ALTER TABLE ONLY product_to_basket
  419.     ADD CONSTRAINT basket_to_product_fkey FOREIGN KEY (basket_id) REFERENCES basket(basket_id);
  420.  
  421.  
  422. --
  423. -- TOC entry 2031 (class 2606 OID 50719)
  424. -- Name: baskets_to_users_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  425. --
  426.  
  427. ALTER TABLE ONLY basket
  428.     ADD CONSTRAINT baskets_to_users_id_fkey FOREIGN KEY (user_id) REFERENCES user_account(user_id);
  429.  
  430.  
  431. --
  432. -- TOC entry 2034 (class 2606 OID 75353)
  433. -- Name: product_to_basket_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  434. --
  435.  
  436. ALTER TABLE ONLY product_to_basket
  437.     ADD CONSTRAINT product_to_basket_fkey FOREIGN KEY (product_id) REFERENCES product(product_id);
  438.  
  439.  
  440. --
  441. -- TOC entry 2033 (class 2606 OID 50777)
  442. -- Name: roles_to_users_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  443. --
  444.  
  445. ALTER TABLE ONLY user_account_to_role
  446.     ADD CONSTRAINT roles_to_users_fkey FOREIGN KEY (role_id) REFERENCES role(role_id);
  447.  
  448.  
  449. --
  450. -- TOC entry 2032 (class 2606 OID 50772)
  451. -- Name: users_to_roles_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  452. --
  453.  
  454. ALTER TABLE ONLY user_account_to_role
  455.     ADD CONSTRAINT users_to_roles_fkey FOREIGN KEY (user_id) REFERENCES user_account(user_id);
  456.  
  457.  
  458. --
  459. -- TOC entry 2168 (class 0 OID 0)
  460. -- Dependencies: 6
  461. -- Name: public; Type: ACL; Schema: -; Owner: postgres
  462. --
  463.  
  464. REVOKE ALL ON SCHEMA public FROM PUBLIC;
  465. REVOKE ALL ON SCHEMA public FROM postgres;
  466. GRANT ALL ON SCHEMA public TO postgres;
  467. GRANT ALL ON SCHEMA public TO PUBLIC;
  468.  
  469.  
  470. -- Completed on 2018-09-17 16:55:33
  471.  
  472. --
  473. -- PostgreSQL database dump complete
  474. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement