diff --git a/init/init-user-db.sh b/init/init-user-db.sh
index 2f65f99fa34acb6b7729c78c1044d9ded108060f..b84443d5012df7701e60977f9381329622938662 100644
--- a/init/init-user-db.sh
+++ b/init/init-user-db.sh
@@ -14,6 +14,7 @@ do
     REVOKE connect ON DATABASE $user FROM PUBLIC;
     GRANT ALL PRIVILEGES ON DATABASE $user TO $user;
     ALTER USER $user WITH PASSWORD '$user_pw';
+    GRANT pg_read_server_files TO $user;
 EOSQL
 
     echo Creating user sample database
diff --git a/init/sample/dvdrental.sql b/init/sample/dvdrental.sql
index 4da701b3a8da95407ee0faf5d11b7c7832e0e828..38c93419a30ea3b9f99226167b48f528de2070ad 100644
--- a/init/sample/dvdrental.sql
+++ b/init/sample/dvdrental.sql
@@ -1,171 +1,4 @@
 --
--- NOTE:
---
--- File paths need to be edited. Search for $$PATH$$ and
--- replace it with the path to the directory containing
--- the extracted data files.
---
---
--- PostgreSQL database dump
---
-
-SET statement_timeout = 0;
-SET client_encoding = 'UTF8';
-SET standard_conforming_strings = on;
-SET check_function_bodies = false;
-SET client_min_messages = warning;
-
-SET search_path = public, pg_catalog;
-
-ALTER TABLE ONLY public.store DROP CONSTRAINT store_manager_staff_id_fkey;
-ALTER TABLE ONLY public.store DROP CONSTRAINT store_address_id_fkey;
-ALTER TABLE ONLY public.staff DROP CONSTRAINT staff_address_id_fkey;
-ALTER TABLE ONLY public.rental DROP CONSTRAINT rental_staff_id_key;
-ALTER TABLE ONLY public.rental DROP CONSTRAINT rental_inventory_id_fkey;
-ALTER TABLE ONLY public.rental DROP CONSTRAINT rental_customer_id_fkey;
-ALTER TABLE ONLY public.payment DROP CONSTRAINT payment_staff_id_fkey;
-ALTER TABLE ONLY public.payment DROP CONSTRAINT payment_rental_id_fkey;
-ALTER TABLE ONLY public.payment DROP CONSTRAINT payment_customer_id_fkey;
-ALTER TABLE ONLY public.inventory DROP CONSTRAINT inventory_film_id_fkey;
-ALTER TABLE ONLY public.city DROP CONSTRAINT fk_city;
-ALTER TABLE ONLY public.address DROP CONSTRAINT fk_address_city;
-ALTER TABLE ONLY public.film DROP CONSTRAINT film_language_id_fkey;
-ALTER TABLE ONLY public.film_category DROP CONSTRAINT film_category_film_id_fkey;
-ALTER TABLE ONLY public.film_category DROP CONSTRAINT film_category_category_id_fkey;
-ALTER TABLE ONLY public.film_actor DROP CONSTRAINT film_actor_film_id_fkey;
-ALTER TABLE ONLY public.film_actor DROP CONSTRAINT film_actor_actor_id_fkey;
-ALTER TABLE ONLY public.customer DROP CONSTRAINT customer_address_id_fkey;
-DROP TRIGGER last_updated ON public.store;
-DROP TRIGGER last_updated ON public.staff;
-DROP TRIGGER last_updated ON public.rental;
-DROP TRIGGER last_updated ON public.language;
-DROP TRIGGER last_updated ON public.inventory;
-DROP TRIGGER last_updated ON public.film_category;
-DROP TRIGGER last_updated ON public.film_actor;
-DROP TRIGGER last_updated ON public.film;
-DROP TRIGGER last_updated ON public.customer;
-DROP TRIGGER last_updated ON public.country;
-DROP TRIGGER last_updated ON public.city;
-DROP TRIGGER last_updated ON public.category;
-DROP TRIGGER last_updated ON public.address;
-DROP TRIGGER last_updated ON public.actor;
-DROP TRIGGER film_fulltext_trigger ON public.film;
-DROP INDEX public.idx_unq_rental_rental_date_inventory_id_customer_id;
-DROP INDEX public.idx_unq_manager_staff_id;
-DROP INDEX public.idx_title;
-DROP INDEX public.idx_store_id_film_id;
-DROP INDEX public.idx_last_name;
-DROP INDEX public.idx_fk_store_id;
-DROP INDEX public.idx_fk_staff_id;
-DROP INDEX public.idx_fk_rental_id;
-DROP INDEX public.idx_fk_language_id;
-DROP INDEX public.idx_fk_inventory_id;
-DROP INDEX public.idx_fk_film_id;
-DROP INDEX public.idx_fk_customer_id;
-DROP INDEX public.idx_fk_country_id;
-DROP INDEX public.idx_fk_city_id;
-DROP INDEX public.idx_fk_address_id;
-DROP INDEX public.idx_actor_last_name;
-DROP INDEX public.film_fulltext_idx;
-ALTER TABLE ONLY public.store DROP CONSTRAINT store_pkey;
-ALTER TABLE ONLY public.staff DROP CONSTRAINT staff_pkey;
-ALTER TABLE ONLY public.rental DROP CONSTRAINT rental_pkey;
-ALTER TABLE ONLY public.payment DROP CONSTRAINT payment_pkey;
-ALTER TABLE ONLY public.language DROP CONSTRAINT language_pkey;
-ALTER TABLE ONLY public.inventory DROP CONSTRAINT inventory_pkey;
-ALTER TABLE ONLY public.film DROP CONSTRAINT film_pkey;
-ALTER TABLE ONLY public.film_category DROP CONSTRAINT film_category_pkey;
-ALTER TABLE ONLY public.film_actor DROP CONSTRAINT film_actor_pkey;
-ALTER TABLE ONLY public.customer DROP CONSTRAINT customer_pkey;
-ALTER TABLE ONLY public.country DROP CONSTRAINT country_pkey;
-ALTER TABLE ONLY public.city DROP CONSTRAINT city_pkey;
-ALTER TABLE ONLY public.category DROP CONSTRAINT category_pkey;
-ALTER TABLE ONLY public.address DROP CONSTRAINT address_pkey;
-ALTER TABLE ONLY public.actor DROP CONSTRAINT actor_pkey;
-DROP VIEW public.staff_list;
-DROP VIEW public.sales_by_store;
-DROP TABLE public.store;
-DROP SEQUENCE public.store_store_id_seq;
-DROP TABLE public.staff;
-DROP SEQUENCE public.staff_staff_id_seq;
-DROP VIEW public.sales_by_film_category;
-DROP TABLE public.rental;
-DROP SEQUENCE public.rental_rental_id_seq;
-DROP TABLE public.payment;
-DROP SEQUENCE public.payment_payment_id_seq;
-DROP VIEW public.nicer_but_slower_film_list;
-DROP TABLE public.language;
-DROP SEQUENCE public.language_language_id_seq;
-DROP TABLE public.inventory;
-DROP SEQUENCE public.inventory_inventory_id_seq;
-DROP VIEW public.film_list;
-DROP VIEW public.customer_list;
-DROP TABLE public.country;
-DROP SEQUENCE public.country_country_id_seq;
-DROP TABLE public.city;
-DROP SEQUENCE public.city_city_id_seq;
-DROP TABLE public.address;
-DROP SEQUENCE public.address_address_id_seq;
-DROP VIEW public.actor_info;
-DROP TABLE public.film_category;
-DROP TABLE public.film_actor;
-DROP TABLE public.film;
-DROP SEQUENCE public.film_film_id_seq;
-DROP TABLE public.category;
-DROP SEQUENCE public.category_category_id_seq;
-DROP TABLE public.actor;
-DROP SEQUENCE public.actor_actor_id_seq;
-DROP AGGREGATE public.group_concat(text);
-DROP FUNCTION public.rewards_report(min_monthly_purchases integer, min_dollar_amount_purchased numeric);
-DROP TABLE public.customer;
-DROP SEQUENCE public.customer_customer_id_seq;
-DROP FUNCTION public.last_updated();
-DROP FUNCTION public.last_day(timestamp without time zone);
-DROP FUNCTION public.inventory_in_stock(p_inventory_id integer);
-DROP FUNCTION public.inventory_held_by_customer(p_inventory_id integer);
-DROP FUNCTION public.get_customer_balance(p_customer_id integer, p_effective_date timestamp without time zone);
-DROP FUNCTION public.film_not_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer);
-DROP FUNCTION public.film_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer);
-DROP FUNCTION public._group_concat(text, text);
-DROP DOMAIN public.year;
-DROP TYPE public.mpaa_rating;
-DROP EXTENSION plpgsql;
-DROP SCHEMA public;
---
--- Name: public; Type: SCHEMA; Schema: -; Owner: postgres
---
-
-CREATE SCHEMA public;
-
-
-ALTER SCHEMA public OWNER TO postgres;
-
---
--- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres
---
-
-COMMENT ON SCHEMA public IS 'Standard public schema';
-
-
---
--- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
---
-
-CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
-
-
---
--- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
---
-
-COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
-
-
-SET search_path = public, pg_catalog;
-
---
--- Name: mpaa_rating; Type: TYPE; Schema: public; Owner: postgres
---
 
 CREATE TYPE mpaa_rating AS ENUM (
     'G',
@@ -176,7 +9,7 @@ CREATE TYPE mpaa_rating AS ENUM (
 );
 
 
-ALTER TYPE public.mpaa_rating OWNER TO postgres;
+-- ALTER TYPE mpaa_rating OWNER TO postgres;
 
 --
 -- Name: year; Type: DOMAIN; Schema: public; Owner: postgres
@@ -186,7 +19,7 @@ CREATE DOMAIN year AS integer
 	CONSTRAINT year_check CHECK (((VALUE >= 1901) AND (VALUE <= 2155)));
 
 
-ALTER DOMAIN public.year OWNER TO postgres;
+-- ALTER DOMAIN year OWNER TO postgres;
 
 --
 -- Name: _group_concat(text, text); Type: FUNCTION; Schema: public; Owner: postgres
@@ -203,41 +36,7 @@ END
 $_$;
 
 
-ALTER FUNCTION public._group_concat(text, text) OWNER TO postgres;
-
---
--- Name: film_in_stock(integer, integer); Type: FUNCTION; Schema: public; Owner: postgres
---
-
-CREATE FUNCTION film_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer) RETURNS SETOF integer
-    LANGUAGE sql
-    AS $_$
-     SELECT inventory_id
-     FROM inventory
-     WHERE film_id = $1
-     AND store_id = $2
-     AND inventory_in_stock(inventory_id);
-$_$;
-
-
-ALTER FUNCTION public.film_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer) OWNER TO postgres;
-
---
--- Name: film_not_in_stock(integer, integer); Type: FUNCTION; Schema: public; Owner: postgres
---
-
-CREATE FUNCTION film_not_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer) RETURNS SETOF integer
-    LANGUAGE sql
-    AS $_$
-    SELECT inventory_id
-    FROM inventory
-    WHERE film_id = $1
-    AND store_id = $2
-    AND NOT inventory_in_stock(inventory_id);
-$_$;
-
-
-ALTER FUNCTION public.film_not_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer) OWNER TO postgres;
+-- ALTER FUNCTION film_not_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer) OWNER TO postgres;
 
 --
 -- Name: get_customer_balance(integer, timestamp without time zone); Type: FUNCTION; Schema: public; Owner: postgres
@@ -282,7 +81,7 @@ END
 $$;
 
 
-ALTER FUNCTION public.get_customer_balance(p_customer_id integer, p_effective_date timestamp without time zone) OWNER TO postgres;
+-- ALTER FUNCTION get_customer_balance(p_customer_id integer, p_effective_date timestamp without time zone) OWNER TO postgres;
 
 --
 -- Name: inventory_held_by_customer(integer); Type: FUNCTION; Schema: public; Owner: postgres
@@ -304,7 +103,7 @@ BEGIN
 END $$;
 
 
-ALTER FUNCTION public.inventory_held_by_customer(p_inventory_id integer) OWNER TO postgres;
+
 
 --
 -- Name: inventory_in_stock(integer); Type: FUNCTION; Schema: public; Owner: postgres
@@ -341,7 +140,7 @@ BEGIN
 END $$;
 
 
-ALTER FUNCTION public.inventory_in_stock(p_inventory_id integer) OWNER TO postgres;
+
 
 --
 -- Name: last_day(timestamp without time zone); Type: FUNCTION; Schema: public; Owner: postgres
@@ -359,7 +158,7 @@ CREATE FUNCTION last_day(timestamp without time zone) RETURNS date
 $_$;
 
 
-ALTER FUNCTION public.last_day(timestamp without time zone) OWNER TO postgres;
+
 
 --
 -- Name: last_updated(); Type: FUNCTION; Schema: public; Owner: postgres
@@ -374,7 +173,7 @@ BEGIN
 END $$;
 
 
-ALTER FUNCTION public.last_updated() OWNER TO postgres;
+
 
 --
 -- Name: customer_customer_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -388,7 +187,7 @@ CREATE SEQUENCE customer_customer_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.customer_customer_id_seq OWNER TO postgres;
+
 
 SET default_tablespace = '';
 
@@ -412,7 +211,7 @@ CREATE TABLE customer (
 );
 
 
-ALTER TABLE public.customer OWNER TO postgres;
+
 
 --
 -- Name: rewards_report(integer, numeric); Type: FUNCTION; Schema: public; Owner: postgres
@@ -476,7 +275,7 @@ END
 $_$;
 
 
-ALTER FUNCTION public.rewards_report(min_monthly_purchases integer, min_dollar_amount_purchased numeric) OWNER TO postgres;
+
 
 --
 -- Name: group_concat(text); Type: AGGREGATE; Schema: public; Owner: postgres
@@ -488,7 +287,7 @@ CREATE AGGREGATE group_concat(text) (
 );
 
 
-ALTER AGGREGATE public.group_concat(text) OWNER TO postgres;
+
 
 --
 -- Name: actor_actor_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -502,7 +301,7 @@ CREATE SEQUENCE actor_actor_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.actor_actor_id_seq OWNER TO postgres;
+
 
 --
 -- Name: actor; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -516,7 +315,7 @@ CREATE TABLE actor (
 );
 
 
-ALTER TABLE public.actor OWNER TO postgres;
+
 
 --
 -- Name: category_category_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -530,7 +329,7 @@ CREATE SEQUENCE category_category_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.category_category_id_seq OWNER TO postgres;
+
 
 --
 -- Name: category; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -543,7 +342,7 @@ CREATE TABLE category (
 );
 
 
-ALTER TABLE public.category OWNER TO postgres;
+
 
 --
 -- Name: film_film_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -557,7 +356,7 @@ CREATE SEQUENCE film_film_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.film_film_id_seq OWNER TO postgres;
+
 
 --
 -- Name: film; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -580,7 +379,7 @@ CREATE TABLE film (
 );
 
 
-ALTER TABLE public.film OWNER TO postgres;
+
 
 --
 -- Name: film_actor; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -593,7 +392,7 @@ CREATE TABLE film_actor (
 );
 
 
-ALTER TABLE public.film_actor OWNER TO postgres;
+
 
 --
 -- Name: film_category; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -606,7 +405,7 @@ CREATE TABLE film_category (
 );
 
 
-ALTER TABLE public.film_category OWNER TO postgres;
+
 
 --
 -- Name: actor_info; Type: VIEW; Schema: public; Owner: postgres
@@ -616,7 +415,7 @@ CREATE VIEW actor_info AS
     SELECT a.actor_id, a.first_name, a.last_name, group_concat(DISTINCT (((c.name)::text || ': '::text) || (SELECT group_concat((f.title)::text) AS group_concat FROM ((film f JOIN film_category fc ON ((f.film_id = fc.film_id))) JOIN film_actor fa ON ((f.film_id = fa.film_id))) WHERE ((fc.category_id = c.category_id) AND (fa.actor_id = a.actor_id)) GROUP BY fa.actor_id))) AS film_info FROM (((actor a LEFT JOIN film_actor fa ON ((a.actor_id = fa.actor_id))) LEFT JOIN film_category fc ON ((fa.film_id = fc.film_id))) LEFT JOIN category c ON ((fc.category_id = c.category_id))) GROUP BY a.actor_id, a.first_name, a.last_name;
 
 
-ALTER TABLE public.actor_info OWNER TO postgres;
+
 
 --
 -- Name: address_address_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -630,7 +429,7 @@ CREATE SEQUENCE address_address_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.address_address_id_seq OWNER TO postgres;
+
 
 --
 -- Name: address; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -648,7 +447,7 @@ CREATE TABLE address (
 );
 
 
-ALTER TABLE public.address OWNER TO postgres;
+
 
 --
 -- Name: city_city_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -662,7 +461,7 @@ CREATE SEQUENCE city_city_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.city_city_id_seq OWNER TO postgres;
+
 
 --
 -- Name: city; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -676,7 +475,7 @@ CREATE TABLE city (
 );
 
 
-ALTER TABLE public.city OWNER TO postgres;
+
 
 --
 -- Name: country_country_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -690,7 +489,7 @@ CREATE SEQUENCE country_country_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.country_country_id_seq OWNER TO postgres;
+
 
 --
 -- Name: country; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -703,7 +502,7 @@ CREATE TABLE country (
 );
 
 
-ALTER TABLE public.country OWNER TO postgres;
+
 
 --
 -- Name: customer_list; Type: VIEW; Schema: public; Owner: postgres
@@ -713,7 +512,7 @@ CREATE VIEW customer_list AS
     SELECT cu.customer_id AS id, (((cu.first_name)::text || ' '::text) || (cu.last_name)::text) AS name, a.address, a.postal_code AS "zip code", a.phone, city.city, country.country, CASE WHEN cu.activebool THEN 'active'::text ELSE ''::text END AS notes, cu.store_id AS sid FROM (((customer cu JOIN address a ON ((cu.address_id = a.address_id))) JOIN city ON ((a.city_id = city.city_id))) JOIN country ON ((city.country_id = country.country_id)));
 
 
-ALTER TABLE public.customer_list OWNER TO postgres;
+
 
 --
 -- Name: film_list; Type: VIEW; Schema: public; Owner: postgres
@@ -723,7 +522,7 @@ CREATE VIEW film_list AS
     SELECT film.film_id AS fid, film.title, film.description, category.name AS category, film.rental_rate AS price, film.length, film.rating, group_concat((((actor.first_name)::text || ' '::text) || (actor.last_name)::text)) AS actors FROM ((((category LEFT JOIN film_category ON ((category.category_id = film_category.category_id))) LEFT JOIN film ON ((film_category.film_id = film.film_id))) JOIN film_actor ON ((film.film_id = film_actor.film_id))) JOIN actor ON ((film_actor.actor_id = actor.actor_id))) GROUP BY film.film_id, film.title, film.description, category.name, film.rental_rate, film.length, film.rating;
 
 
-ALTER TABLE public.film_list OWNER TO postgres;
+
 
 --
 -- Name: inventory_inventory_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -737,7 +536,7 @@ CREATE SEQUENCE inventory_inventory_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.inventory_inventory_id_seq OWNER TO postgres;
+
 
 --
 -- Name: inventory; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -751,7 +550,7 @@ CREATE TABLE inventory (
 );
 
 
-ALTER TABLE public.inventory OWNER TO postgres;
+
 
 --
 -- Name: language_language_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -765,7 +564,7 @@ CREATE SEQUENCE language_language_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.language_language_id_seq OWNER TO postgres;
+
 
 --
 -- Name: language; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -778,7 +577,7 @@ CREATE TABLE language (
 );
 
 
-ALTER TABLE public.language OWNER TO postgres;
+
 
 --
 -- Name: nicer_but_slower_film_list; Type: VIEW; Schema: public; Owner: postgres
@@ -788,7 +587,7 @@ CREATE VIEW nicer_but_slower_film_list AS
     SELECT film.film_id AS fid, film.title, film.description, category.name AS category, film.rental_rate AS price, film.length, film.rating, group_concat((((upper("substring"((actor.first_name)::text, 1, 1)) || lower("substring"((actor.first_name)::text, 2))) || upper("substring"((actor.last_name)::text, 1, 1))) || lower("substring"((actor.last_name)::text, 2)))) AS actors FROM ((((category LEFT JOIN film_category ON ((category.category_id = film_category.category_id))) LEFT JOIN film ON ((film_category.film_id = film.film_id))) JOIN film_actor ON ((film.film_id = film_actor.film_id))) JOIN actor ON ((film_actor.actor_id = actor.actor_id))) GROUP BY film.film_id, film.title, film.description, category.name, film.rental_rate, film.length, film.rating;
 
 
-ALTER TABLE public.nicer_but_slower_film_list OWNER TO postgres;
+
 
 --
 -- Name: payment_payment_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -802,7 +601,7 @@ CREATE SEQUENCE payment_payment_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.payment_payment_id_seq OWNER TO postgres;
+
 
 --
 -- Name: payment; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -818,7 +617,7 @@ CREATE TABLE payment (
 );
 
 
-ALTER TABLE public.payment OWNER TO postgres;
+
 
 --
 -- Name: rental_rental_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -832,7 +631,7 @@ CREATE SEQUENCE rental_rental_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.rental_rental_id_seq OWNER TO postgres;
+
 
 --
 -- Name: rental; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -849,7 +648,7 @@ CREATE TABLE rental (
 );
 
 
-ALTER TABLE public.rental OWNER TO postgres;
+
 
 --
 -- Name: sales_by_film_category; Type: VIEW; Schema: public; Owner: postgres
@@ -859,7 +658,7 @@ CREATE VIEW sales_by_film_category AS
     SELECT c.name AS category, sum(p.amount) AS total_sales FROM (((((payment p JOIN rental r ON ((p.rental_id = r.rental_id))) JOIN inventory i ON ((r.inventory_id = i.inventory_id))) JOIN film f ON ((i.film_id = f.film_id))) JOIN film_category fc ON ((f.film_id = fc.film_id))) JOIN category c ON ((fc.category_id = c.category_id))) GROUP BY c.name ORDER BY sum(p.amount) DESC;
 
 
-ALTER TABLE public.sales_by_film_category OWNER TO postgres;
+
 
 --
 -- Name: staff_staff_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -873,7 +672,7 @@ CREATE SEQUENCE staff_staff_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.staff_staff_id_seq OWNER TO postgres;
+
 
 --
 -- Name: staff; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -894,7 +693,7 @@ CREATE TABLE staff (
 );
 
 
-ALTER TABLE public.staff OWNER TO postgres;
+
 
 --
 -- Name: store_store_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
@@ -908,7 +707,7 @@ CREATE SEQUENCE store_store_id_seq
     CACHE 1;
 
 
-ALTER TABLE public.store_store_id_seq OWNER TO postgres;
+
 
 --
 -- Name: store; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
@@ -922,7 +721,7 @@ CREATE TABLE store (
 );
 
 
-ALTER TABLE public.store OWNER TO postgres;
+
 
 --
 -- Name: sales_by_store; Type: VIEW; Schema: public; Owner: postgres
@@ -932,7 +731,7 @@ CREATE VIEW sales_by_store AS
     SELECT (((c.city)::text || ','::text) || (cy.country)::text) AS store, (((m.first_name)::text || ' '::text) || (m.last_name)::text) AS manager, sum(p.amount) AS total_sales FROM (((((((payment p JOIN rental r ON ((p.rental_id = r.rental_id))) JOIN inventory i ON ((r.inventory_id = i.inventory_id))) JOIN store s ON ((i.store_id = s.store_id))) JOIN address a ON ((s.address_id = a.address_id))) JOIN city c ON ((a.city_id = c.city_id))) JOIN country cy ON ((c.country_id = cy.country_id))) JOIN staff m ON ((s.manager_staff_id = m.staff_id))) GROUP BY cy.country, c.city, s.store_id, m.first_name, m.last_name ORDER BY cy.country, c.city;
 
 
-ALTER TABLE public.sales_by_store OWNER TO postgres;
+
 
 --
 -- Name: staff_list; Type: VIEW; Schema: public; Owner: postgres
@@ -942,7 +741,36 @@ CREATE VIEW staff_list AS
     SELECT s.staff_id AS id, (((s.first_name)::text || ' '::text) || (s.last_name)::text) AS name, a.address, a.postal_code AS "zip code", a.phone, city.city, country.country, s.store_id AS sid FROM (((staff s JOIN address a ON ((s.address_id = a.address_id))) JOIN city ON ((a.city_id = city.city_id))) JOIN country ON ((city.country_id = country.country_id)));
 
 
-ALTER TABLE public.staff_list OWNER TO postgres;
+
+--
+-- Name: film_in_stock(integer, integer); Type: FUNCTION; Schema: public; Owner: postgres
+--
+
+CREATE FUNCTION film_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer) RETURNS SETOF integer
+    LANGUAGE sql
+    AS $_$
+     SELECT inventory_id
+     FROM inventory
+     WHERE film_id = $1
+     AND store_id = $2
+     AND inventory_in_stock(inventory_id);
+$_$;
+
+
+--
+-- Name: film_not_in_stock(integer, integer); Type: FUNCTION; Schema: public; Owner: postgres
+--
+
+CREATE FUNCTION film_not_in_stock(p_film_id integer, p_store_id integer, OUT p_film_count integer) RETURNS SETOF integer
+    LANGUAGE sql
+    AS $_$
+    SELECT inventory_id
+    FROM inventory
+    WHERE film_id = $1
+    AND store_id = $2
+    AND NOT inventory_in_stock(inventory_id);
+$_$;
+
 
 --
 -- Data for Name: actor; Type: TABLE DATA; Schema: public; Owner: postgres
@@ -1643,16 +1471,6 @@ ALTER TABLE ONLY store
     ADD CONSTRAINT store_manager_staff_id_fkey FOREIGN KEY (manager_staff_id) REFERENCES staff(staff_id) ON UPDATE CASCADE ON DELETE RESTRICT;
 
 
---
--- 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;
-
-
 --
 -- PostgreSQL database dump complete
 --