-------------------------------------------------------------------------------
-- Template for Assignment 3 (SQL)
-------------------------------------------------------------------------------

-- Add a DROP statement for each database object you create in your
-- solutions. This allows the script to be loaded more than once
-- without errors.

WHENEVER ERROR CONTINUE; -- Suppress error messages when dropping
SET OUTPUT OFF;          -- non-existing tables

-- As an example we have added a statement to drop the table
-- 'CHEAPITEMS' defined in question '13'

DROP TABLE cheapitems CASCADE;

-- ADD MORE 'DROP ...' STATEMENTS HERE:
-- DROP ...


-- Show error messages and exit if there is an error
WHENEVER ERROR EXIT;
SET OUTPUT ON;
-- Set log file
SET ECHO ON;
SET PAGELENGTH 0;
SET INPUT, OUTPUT LOG ON;

-- EDIT THIS LINE AND CHANGE <user_name> WITH YOUR USER NAME:
LOG INPUT, OUTPUT ON 'dbt-3-<user_name>.log';


-------------------------------------------------------------------------------
-- Fill in your solutions below
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
-- Part 1: SQL - Queries and views
-------------------------------------------------------------------------------

-- 1 --

-- 2 --

-- 3 --

-- 4 --

-- 5 --

-- 6 --

-- 7 --

-- 8 --

-- 9 --

-- 10 --

-- 11 --

-- 12 --

-- 13 --
-- create table cheapitems
-- ...

-- 14 --

-- 15 --

-- 16 --

-- 17 --


-------------------------------------------------------------------------------
-- Part 2: Database Integrity - Assertions, Triggers, and Stored Procedures
-------------------------------------------------------------------------------

-- 1 --

-- 2 --

-- 3 --

-- 4 --

-- 5 --

-- 6 --


-- exit --
exit;