--
-- PostgreSQL database dump
--

SET search_path = public, pg_catalog;

--
-- TOC entry 4 (OID 97924)
-- Name: recipes; Type: TABLE; Schema: public; Owner: projectjj
--

CREATE TABLE recipes (
    recipe_id serial NOT NULL,
    recipe_name text NOT NULL,
    recipe_persons smallint DEFAULT 1 NOT NULL,
    recipe_prepare_time interval,
    recipe_work_time interval,
    recipe_picture text,
    recipe_comment text,
    recipe_type integer,
    recipe_vegetarian boolean DEFAULT false NOT NULL,
    recipe_instructions text
) WITHOUT OIDS;


--
-- TOC entry 5 (OID 97933)
-- Name: recipe_types; Type: TABLE; Schema: public; Owner: projectjj
--

CREATE TABLE recipe_types (
    recipe_type_id serial NOT NULL,
    recipe_type_type text NOT NULL
) WITHOUT OIDS;


--
-- TOC entry 6 (OID 97951)
-- Name: ingredient_units; Type: TABLE; Schema: public; Owner: projectjj
--

CREATE TABLE ingredient_units (
    ingredient_unit_id serial NOT NULL,
    ingredient_unit_unit text NOT NULL
) WITHOUT OIDS;


--
-- TOC entry 7 (OID 97961)
-- Name: ingredient_types; Type: TABLE; Schema: public; Owner: projectjj
--

CREATE TABLE ingredient_types (
    ingredient_type_id serial NOT NULL,
    ingredient_type_type text NOT NULL
) WITHOUT OIDS;


--
-- TOC entry 8 (OID 97971)
-- Name: ingredients; Type: TABLE; Schema: public; Owner: projectjj
--

CREATE TABLE ingredients (
    ingredient_id serial NOT NULL,
    ingredient_name text NOT NULL,
    ingredient_type integer,
    ingredient_unit integer,
    ingredient_price real
) WITHOUT OIDS;


--
-- TOC entry 9 (OID 97987)
-- Name: recipe_ingredients; Type: TABLE; Schema: public; Owner: projectjj
--

CREATE TABLE recipe_ingredients (
    recipe_id integer NOT NULL,
    ingredient_id integer NOT NULL,
    ingredient_units real NOT NULL
) WITHOUT OIDS;


--
-- TOC entry 10 (OID 98001)
-- Name: menus; Type: TABLE; Schema: public; Owner: projectjj
--

CREATE TABLE menus (
    menu_id serial NOT NULL,
    menu_name text NOT NULL,
    menu_comment text
) WITHOUT OIDS;


--
-- TOC entry 11 (OID 98009)
-- Name: menu_recipes; Type: TABLE; Schema: public; Owner: projectjj
--

CREATE TABLE menu_recipes (
    menu_id integer NOT NULL,
    recipe_id integer NOT NULL,
    recipe_order smallint NOT NULL
) WITHOUT OIDS;


--
-- TOC entry 12 (OID 98023)
-- Name: inventories; Type: TABLE; Schema: public; Owner: projectjj
--

CREATE TABLE inventories (
    inventory_id serial NOT NULL,
    inventory_name text NOT NULL,
    inventory_begin date,
    inventory_end date
) WITHOUT OIDS;


--
-- TOC entry 13 (OID 98031)
-- Name: inventory_ingredients; Type: TABLE; Schema: public; Owner: projectjj
--

CREATE TABLE inventory_ingredients (
    inventory_id integer NOT NULL,
    ingredient_id integer NOT NULL,
    ingredient_units real
) WITHOUT OIDS;


SET check_function_bodies = false;

--
-- TOC entry 33 (OID 98149)
-- Name: _int_contains(integer[], integer[]); Type: FUNCTION; Schema: public; Owner: projectjj
--

CREATE FUNCTION _int_contains(integer[], integer[]) RETURNS boolean
    AS '$libdir/_int', '_int_contains'
    LANGUAGE c STRICT;


--
-- TOC entry 35 (OID 98150)
-- Name: _int_contained(integer[], integer[]); Type: FUNCTION; Schema: public; Owner: projectjj
--

CREATE FUNCTION _int_contained(integer[], integer[]) RETURNS boolean
    AS '$libdir/_int', '_int_contained'
    LANGUAGE c STRICT;


--
-- Data for TOC entry 37 (OID 97924)
-- Name: recipes; Type: TABLE DATA; Schema: public; Owner: projectjj
--

INSERT INTO recipes VALUES (1, 'Meat Balls (beef)', 4, '00:40:00', '00:20:00', 'http://i.pjj.cc/160f48b557e03b1891bb24e173680d1f.jpg', 'Bla bla, comments...', 7, false, 'Bla bla bla, instructions...');
INSERT INTO recipes VALUES (2, 'Pasta with Tomato Sauce', 4, '00:40:00', '00:10:00', 'http://i.pjj.cc/6165ba745a824d9d74ff0e885d6815fd.jpg', 'Bla bla, comments...', 6, true, 'Bla bla bla, instructions...');


--
-- Data for TOC entry 38 (OID 97933)
-- Name: recipe_types; Type: TABLE DATA; Schema: public; Owner: projectjj
--

INSERT INTO recipe_types VALUES (1, 'Dessert');
INSERT INTO recipe_types VALUES (2, 'Hors d''oeuvre');
INSERT INTO recipe_types VALUES (3, 'Game Dish');
INSERT INTO recipe_types VALUES (4, 'Breakfast');
INSERT INTO recipe_types VALUES (5, 'Lunch');
INSERT INTO recipe_types VALUES (6, 'Main Course');
INSERT INTO recipe_types VALUES (7, 'Side Dish');


--
-- Data for TOC entry 39 (OID 97951)
-- Name: ingredient_units; Type: TABLE DATA; Schema: public; Owner: projectjj
--

INSERT INTO ingredient_units VALUES (1, 'g');
INSERT INTO ingredient_units VALUES (2, 'kg');
INSERT INTO ingredient_units VALUES (3, 'L');
INSERT INTO ingredient_units VALUES (4, 'dL');
INSERT INTO ingredient_units VALUES (5, 'pcs');


--
-- Data for TOC entry 40 (OID 97961)
-- Name: ingredient_types; Type: TABLE DATA; Schema: public; Owner: projectjj
--

INSERT INTO ingredient_types VALUES (1, 'Fruit');
INSERT INTO ingredient_types VALUES (2, 'Vegetable');
INSERT INTO ingredient_types VALUES (3, 'Pork');
INSERT INTO ingredient_types VALUES (4, 'Beef');
INSERT INTO ingredient_types VALUES (5, 'Other');
INSERT INTO ingredient_types VALUES (6, 'Other meat');
INSERT INTO ingredient_types VALUES (7, 'Other non-meat');


--
-- Data for TOC entry 41 (OID 97971)
-- Name: ingredients; Type: TABLE DATA; Schema: public; Owner: projectjj
--

INSERT INTO ingredients VALUES (4, 'Ground Pork', 3, 2, 80);
INSERT INTO ingredients VALUES (1, 'Apple', 1, 5, 2);
INSERT INTO ingredients VALUES (10, 'Chicken', 6, 2, 60);
INSERT INTO ingredients VALUES (2, 'Cucumber', 2, 5, 10);
INSERT INTO ingredients VALUES (5, 'Flour', 7, 2, 5);
INSERT INTO ingredients VALUES (13, 'Fresh Pasta', 7, 2, 40);
INSERT INTO ingredients VALUES (14, 'Oregano', 7, 1, 2);
INSERT INTO ingredients VALUES (15, 'Tomato Sauce', 7, 3, 10);
INSERT INTO ingredients VALUES (3, 'Ground Beef', 4, 2, 80);
INSERT INTO ingredients VALUES (12, 'Pasta', 7, 2, 10);
INSERT INTO ingredients VALUES (8, 'Salt', 6, 1, 0.25);
INSERT INTO ingredients VALUES (11, 'Honey', 5, 1, 6);
INSERT INTO ingredients VALUES (6, 'Egg', 5, 5, 2);
INSERT INTO ingredients VALUES (17, 'Whip cream', 5, 4, 23);


--
-- Data for TOC entry 42 (OID 97987)
-- Name: recipe_ingredients; Type: TABLE DATA; Schema: public; Owner: projectjj
--

INSERT INTO recipe_ingredients VALUES (1, 3, 1);
INSERT INTO recipe_ingredients VALUES (1, 5, 0.1);
INSERT INTO recipe_ingredients VALUES (1, 6, 3);
INSERT INTO recipe_ingredients VALUES (2, 8, 4);
INSERT INTO recipe_ingredients VALUES (2, 13, 1.5);
INSERT INTO recipe_ingredients VALUES (2, 14, 2.5);
INSERT INTO recipe_ingredients VALUES (2, 15, 1);


--
-- Data for TOC entry 43 (OID 98001)
-- Name: menus; Type: TABLE DATA; Schema: public; Owner: projectjj
--

INSERT INTO menus VALUES (1, 'Pasta with Tomato Sauce and Meat Balls', NULL);


--
-- Data for TOC entry 44 (OID 98009)
-- Name: menu_recipes; Type: TABLE DATA; Schema: public; Owner: projectjj
--

INSERT INTO menu_recipes VALUES (1, 2, 10);
INSERT INTO menu_recipes VALUES (1, 1, 11);


--
-- Data for TOC entry 45 (OID 98023)
-- Name: inventories; Type: TABLE DATA; Schema: public; Owner: projectjj
--

INSERT INTO inventories VALUES (1, 'Yule', '2004-12-23', '2004-12-25');
INSERT INTO inventories VALUES (2, 'New Years Eve', '2004-12-31', '2004-12-31');
INSERT INTO inventories VALUES (3, 'Birthday', '2004-09-18', '2004-09-18');
INSERT INTO inventories VALUES (0, 'Current', '0001-01-01', '9999-12-31');


--
-- Data for TOC entry 46 (OID 98031)
-- Name: inventory_ingredients; Type: TABLE DATA; Schema: public; Owner: projectjj
--

INSERT INTO inventory_ingredients VALUES (0, 2, 5);
INSERT INTO inventory_ingredients VALUES (0, 1, 20);
INSERT INTO inventory_ingredients VALUES (0, 10, 2);
INSERT INTO inventory_ingredients VALUES (0, 11, 3);
INSERT INTO inventory_ingredients VALUES (1, 5, 200);
INSERT INTO inventory_ingredients VALUES (1, 6, 300);
INSERT INTO inventory_ingredients VALUES (1, 8, 100);
INSERT INTO inventory_ingredients VALUES (0, 3, 2);
INSERT INTO inventory_ingredients VALUES (0, 5, 2);
INSERT INTO inventory_ingredients VALUES (0, 6, 6);
INSERT INTO inventory_ingredients VALUES (0, 8, 5);


--
-- TOC entry 21 (OID 97948)
-- Name: fki_; Type: INDEX; Schema: public; Owner: projectjj
--

CREATE INDEX fki_ ON recipes USING btree (recipe_type);


--
-- TOC entry 23 (OID 97940)
-- Name: recipe_types_pkey; Type: CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY recipe_types
    ADD CONSTRAINT recipe_types_pkey PRIMARY KEY (recipe_type_id);


--
-- TOC entry 22 (OID 97942)
-- Name: recipes_pkey; Type: CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY recipes
    ADD CONSTRAINT recipes_pkey PRIMARY KEY (recipe_id);


--
-- TOC entry 24 (OID 97957)
-- Name: ingredient_units_pkey; Type: CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY ingredient_units
    ADD CONSTRAINT ingredient_units_pkey PRIMARY KEY (ingredient_unit_id);


--
-- TOC entry 25 (OID 97967)
-- Name: ingredient_types_pkey; Type: CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY ingredient_types
    ADD CONSTRAINT ingredient_types_pkey PRIMARY KEY (ingredient_type_id);


--
-- TOC entry 27 (OID 97977)
-- Name: ingredients_pkey; Type: CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY ingredients
    ADD CONSTRAINT ingredients_pkey PRIMARY KEY (ingredient_id);


--
-- TOC entry 28 (OID 97997)
-- Name: recipe_ingredients_pkey; Type: CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY recipe_ingredients
    ADD CONSTRAINT recipe_ingredients_pkey PRIMARY KEY (recipe_id, ingredient_id);


--
-- TOC entry 29 (OID 98007)
-- Name: menus_pkey; Type: CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY menus
    ADD CONSTRAINT menus_pkey PRIMARY KEY (menu_id);


--
-- TOC entry 30 (OID 98019)
-- Name: menu_recipes_pkey; Type: CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY menu_recipes
    ADD CONSTRAINT menu_recipes_pkey PRIMARY KEY (menu_id, recipe_id);


--
-- TOC entry 31 (OID 98029)
-- Name: inventories_pkey; Type: CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY inventories
    ADD CONSTRAINT inventories_pkey PRIMARY KEY (inventory_id);


--
-- TOC entry 32 (OID 98041)
-- Name: inventory_ingredients_pkey; Type: CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY inventory_ingredients
    ADD CONSTRAINT inventory_ingredients_pkey PRIMARY KEY (inventory_id, ingredient_id);


--
-- TOC entry 26 (OID 98124)
-- Name: ingredients_ingredient_name_key; Type: CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY ingredients
    ADD CONSTRAINT ingredients_ingredient_name_key UNIQUE (ingredient_name);


--
-- TOC entry 47 (OID 97944)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY recipes
    ADD CONSTRAINT "$1" FOREIGN KEY (recipe_type) REFERENCES recipe_types(recipe_type_id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- TOC entry 49 (OID 97979)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY ingredients
    ADD CONSTRAINT "$1" FOREIGN KEY (ingredient_type) REFERENCES ingredient_types(ingredient_type_id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- TOC entry 48 (OID 97983)
-- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY ingredients
    ADD CONSTRAINT "$2" FOREIGN KEY (ingredient_unit) REFERENCES ingredient_units(ingredient_unit_id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- TOC entry 51 (OID 97989)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY recipe_ingredients
    ADD CONSTRAINT "$1" FOREIGN KEY (recipe_id) REFERENCES recipes(recipe_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 50 (OID 97993)
-- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY recipe_ingredients
    ADD CONSTRAINT "$2" FOREIGN KEY (ingredient_id) REFERENCES ingredients(ingredient_id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- TOC entry 53 (OID 98011)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY menu_recipes
    ADD CONSTRAINT "$1" FOREIGN KEY (menu_id) REFERENCES menus(menu_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 52 (OID 98015)
-- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY menu_recipes
    ADD CONSTRAINT "$2" FOREIGN KEY (recipe_id) REFERENCES recipes(recipe_id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- TOC entry 55 (OID 98033)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY inventory_ingredients
    ADD CONSTRAINT "$1" FOREIGN KEY (inventory_id) REFERENCES inventories(inventory_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 54 (OID 98037)
-- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: projectjj
--

ALTER TABLE ONLY inventory_ingredients
    ADD CONSTRAINT "$2" FOREIGN KEY (ingredient_id) REFERENCES ingredients(ingredient_id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- TOC entry 14 (OID 97922)
-- Name: recipes_recipe_id_seq; Type: SEQUENCE SET; Schema: public; Owner: projectjj
--

SELECT pg_catalog.setval('recipes_recipe_id_seq', 2, true);


--
-- TOC entry 15 (OID 97931)
-- Name: recipe_types_recipe_type_id_seq; Type: SEQUENCE SET; Schema: public; Owner: projectjj
--

SELECT pg_catalog.setval('recipe_types_recipe_type_id_seq', 7, true);


--
-- TOC entry 16 (OID 97949)
-- Name: ingredient_units_ingredient_unit_id_seq; Type: SEQUENCE SET; Schema: public; Owner: projectjj
--

SELECT pg_catalog.setval('ingredient_units_ingredient_unit_id_seq', 5, true);


--
-- TOC entry 17 (OID 97959)
-- Name: ingredient_types_ingredient_type_id_seq; Type: SEQUENCE SET; Schema: public; Owner: projectjj
--

SELECT pg_catalog.setval('ingredient_types_ingredient_type_id_seq', 7, true);


--
-- TOC entry 18 (OID 97969)
-- Name: ingredients_ingredient_id_seq; Type: SEQUENCE SET; Schema: public; Owner: projectjj
--

SELECT pg_catalog.setval('ingredients_ingredient_id_seq', 17, true);


--
-- TOC entry 19 (OID 97999)
-- Name: menus_menu_id_seq; Type: SEQUENCE SET; Schema: public; Owner: projectjj
--

SELECT pg_catalog.setval('menus_menu_id_seq', 1, true);


--
-- TOC entry 20 (OID 98021)
-- Name: inventories_inventory_id_seq; Type: SEQUENCE SET; Schema: public; Owner: projectjj
--

SELECT pg_catalog.setval('inventories_inventory_id_seq', 3, true);


--
-- TOC entry 2 (OID 2200)
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres
--

COMMENT ON SCHEMA public IS 'Standard public schema';


--
-- TOC entry 34 (OID 98149)
-- Name: FUNCTION _int_contains(integer[], integer[]); Type: COMMENT; Schema: public; Owner: projectjj
--

COMMENT ON FUNCTION _int_contains(integer[], integer[]) IS 'contains';


--
-- TOC entry 36 (OID 98150)
-- Name: FUNCTION _int_contained(integer[], integer[]); Type: COMMENT; Schema: public; Owner: projectjj
--

COMMENT ON FUNCTION _int_contained(integer[], integer[]) IS 'contained in';


