SlideShare a Scribd company logo
1 of 220
PROG3040 Assignment 1 – Fall 2013 Glenn
Paulley – 2A605, x2525
Assignment Type: INDIVIDUAL
Due Date: 2-October-2013 (Wednesday), 10 a.m.
Submission: via D2L drop-box; please take all of the files
documented below and combine them into a single .zip file
using WinZip so that your D2L submission is a single .zip file.
In addition, paper output (script and results for marking) is due
in class on 3 October 2013 (or before).
Instructions:
· Ensure that you have run the latest version of the database
creation script files located in
K:GPAULLEYPROG3040DATABASESPLSQL_WORKBOO
Kstoredbcreate_workbook_store.sql to create the required
tables and data.
· Familiarize yourself with the assignment standards. You
should, at a minimum, capitalize SQL language keywords.
Identifiers may be in lower case or mixed case – strive for
consistency. Be neat.
Task 1. Database design and functional dependencies. [10
marks]
Closure: Certain functional dependencies imply others. Given a
set F of functional dependencies that hold for a table R, the
closureF+ of that set is the set of all FDs implied by the FDs in
F. F+ can be computed by applying Armstrong’s axioms to F.
Furthermore, given a subset Z of the attributes of a table R, and
a set F of functional dependencies that hold for R, the
closureZ+ of Z is defined as the set X of the attributes of R such
that the functional dependency Z X is a member of F+.
If the closures F+ and G+ of two sets of dependencies F and G
are equal, then we say that F and G are equivalent.
To repeat from class, here are Armstrong’s axioms for
functional dependencies, and additional axioms that can be
derived from Armstrong’s original three axioms. Remember that
X, Y, and Z are sets of attributes:
1. Inclusion: if Y is a subset of X, then X Y.
2. Augmentation: if X Y then WX WY.
3. Transitivity: if X Y and Y Z then X Z.
Other axioms:
· Self-determination: for any X, X X. X X is known as a trivial
functional dependency.
· Union: if X Y and X Z then X YZ.
· Decomposition: if X YZ then X Y and X Z.
· Composition: if X Y and W Z, then XW YZ.
· Pseudo-transitivity: if X Y and WY Z then XW Z.
Example. Suppose we have a table R with non-null attributes A,
B, C, D; we commonly write this as
R( A, B, C, D).
Further suppose we have the following set F of non-trivial
functional dependencies:
· A B
· B C
· BC D
We can determine the closure A+ of A as follows:
We are given A B. Trivially, attribute A functionally
determines itself, so we have A A. Since we are given B C, by
transitivity we have A C (because A B and B C, thus A C).
Combining these through union, we have A ABC. Finally, with
BC D, again by transitivity we have A D, because A BC and
BC D, and therefore A D. Combining again, we have A
ABCD, that is, A functionally determines all of the attributes of
R. (Aside: hence A is called a superkey of R).
Task 1, Question 1:
Suppose we have the table S with non-null attributes A through
G; that is, we have
S( A, B, C, D, E, F, G).
Suppose we are given that S satisfies the following set G of
non-trivial functional dependencies:
· A B
· BC DE
· AEF G
(1a). Determine the closure { A,C }+ under this set G of
functional dependencies; remember that closure includes self-
determination. Remember from mathematics that a pair of
braces ({}) denotes a set; hence {A,C} denotes a set made up of
the union of attributes from the sets A and C.
Is the closure {A,C }+ equal to (choose one only):
i.) ABC
ii.) ABCDE
iii.) AC
iv.) ABCDEFG
v.) ACDFG
(1b). Is the functional dependency ACF DG implied by G?
(Answer yes or no).
Submit your responses to 1(a) and 1(b) in a separate text file.
Name your file Task1Q1XX.txt where XX are your first and last
initials. You’ll include this file in your D2L submission.
Task 1, Question 2: [30 marks]
Create an SQL script that creates a set of tables in Boyce-Codd
Normal Form to represent entities in an order/entry system.
Note: as is often the case, there is no “right answer” for doing
this; logical database design is always subject to tradeoffs
because normalizing every functional dependency usually isn’t
desirable. For example, we usually do not decompose the
functional dependency address postal code because there is
little value in doing so. An example from the schema used in the
textbook are the superfluous tables for telephone numbers and
street addresses.
This order/entry system will retain information similar to that
modelled by the Video Store schema documented in the
textbook, but with some differences. To prevent confusion with
the Video Store tables, prefix all of your table names for this
new set of tables with “PG$_”. Use lowercase and underscores
for table and column names and for constraint names.
Your new schema is to include at least the following
information:
· For each customer:
· Customer number (unique)
· Personal information (names)
· “Ship-to” addresses (multiple addresses per customer)
· Balance
· Credit Limit
· Discount percentage
· For each order:
· Order information: customer number, ship-to address, date of
order
· Detail lines (several per order): item number, quantity ordered
· For each item:
· Item number (unique)
· Manufacturing plants (a plant may manufacture many items;
each item may be manufactured by different plants)
· Quantity-on-hand at each plant
· Stock danger level at each plant
· Item description
· For each plant:
· Mailing Address
· Contact information
· Telephone number
· Assume that the company intends to handle tens of thousands
of items in total, and thousands of orders per month.
· Also, for processing reasons a “quantity outstanding” value is
associated with each detail line of each order; this value is
initially set equal to the quantity of the item ordered and is
progressively reduced to zero as (partial) shipments are made.
If you need to create surrogate keys for entities in this schema,
choose data types and formats that are appropriate for the
purpose. Include comment lines in your schema creation script
that documents your proposed surrogate key formats, and why
you chose those formats and data types. In addition to creating
the appropriate tables and their columns, define the appropriate
referential integrity constraints (primary keys and foreign keys)
that relate the tables together. Give each referential constraint
an appropriate name.
Your marks for this question will be based on the “reasonable-
ness” of your design choices. You should provide commentary
(in the form of comments in your SQL script) that explains your
design choices, particularly if there might be debate about such
a choice. Appropriate commentary will enhance your mark.
Create a script file (Task1Q2XX.sql, where XX are your initials
in upper case letters) that creates the tables. You will include
both your completed script file and its output file
(Task1Q2XX.out) to your .zip file submission to D2L.
Task 2. SQL Queries [10 marks each]
Create a script file (Task2XX.sql, where XX are your initials in
upper case letters) to combine the SQL queries for each problem
below, in order. You will submit both your completed script file
and its combined output file (Task2XX.out) to D2L.
1) Write a single SQL query that computes, for each contact, the
average and sum of the rental transactions for rentals that were
made in June 2011 (they could have possibly been returned in
July or later). Include the overall grand total and overall
transaction average in the result. You may not use a UNION
query expression for your answer. For each contact, output:
a. Contact ID
b. Contact last name
c. Contact first name
d. Sum of the contact’s transactions for June 2011, in the format
$9999.99
e. Average of the contact’s transactions for June 2011, in the
format $99.99
f. For the grand total, substitute the literal string ‘June 2011
totals’ for the contact’s last name.
g. Output the list of contacts ordered by first name within last
name.
Hints:
i. Use COALESCE() to substitute the ‘June 2011 totals’ string
in the output
ii. Use GROUP BY ROLLUP
iii. Use a derived table in the FROM clause
iv. You will find the EXTRACT() and TO_CHAR() functions
useful
2) Using the Video Store schema, write a query to produce a list
of items that have never been rented. (Note: there is currently
only one, with the Item ID of 1000). Rewrite your query in at
least three different ways – that are semantically equivalent –
that will return the identical result. Your rewrites may not be
trivial ones – for example, reordering tables in the FROM
clause or reordering predicates in the WHERE clause, or
reversing or negating comparison operations.
3) Using the Video Store schema, write a query to produce a
report that lists the number of times each of the Star Wars
movies were rented in October, 2011. Include the total rental
amount for each of the films. Consider only those movies in
Wide Screen format on DVD. Output the ID of each film, its
title, the number of times it was rented in October 2011 (use the
column heading “Rentals”) and the total rental amount for each
film, using proper money formatting in dollars and cents – use
the column header “Total Amt” for this column. Order your
result by film title.
4) Using the HR schema, write a query that lists all of the
departments located in Seattle, Washington, along with their
managers and the start date for each manager. If a department
does not have a manager, output the value “Unknown”. Output
the manager’s start date using the format “YYYY-MM-DD”. If
the start date for that manager is unknown, also use the literal
“Unknown”. Use appropriate headings for each column in the
result. Order the list by department name.
Task 3. Supplementary task. [5 marks]
You have come into possession of a vintage VHS tape (on two
cassettes) of the film “Lawrence of Arabia”. Add the tape to the
Item table in the Video Store database using an INSERT
statement that contains the necessary SELECT subquery to
determine the proper item type code for this VHS double-set.
COMMIT the change.
Once the film has been added to the database, re-run your
queries from Task 2, Item 2. Ensure that your queries find both
the new “Lawrence of Arabia” film, and the “Pirates of the
Caribbean” film, both of which have yet to be rented.
After your query executes, delete the “Lawrence of Arabia” film
using a DELETE statement, and COMMIT the deletion as part
of your SQL script.
Create a script file (Task3ExtraXX.sql) that creates the new
item, answers the queries, and deletes the item. Submit to D2L
both your completed script file and output file
(Task3ExtraXX.lst).
create_workbook_store.sql
-- create_store.sql
-- Introcution, Oracle Database 11g PL/SQL Programming
Workbook
-- by Michael McLaughlin and John Harper
--
-- This demonstrates building a DVD, Game Cartridge and VHS
tape store.
-- It also highlights constraints and compound check constraints
and
-- seeds the tables with data.
SPOOL create_store.log
SET ECHO OFF
SET FEEDBACK ON
SET NULL '<Null>'
SET PAGESIZE 999
SET SERVEROUTPUT ON
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'SYSTEM_USER') LOOP
EXECUTE IMMEDIATE 'DROP TABLE system_user
CASCADE CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'SYSTEM_USER_S1')
LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE
system_user_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create SYSTEM_USER table and sequence and seed data.
-- ------------------------------------------------------------------
CREATE TABLE system_user
( system_user_id NUMBER CONSTRAINT
pk_system_user PRIMARY KEY
, system_user_name VARCHAR2(20) CONSTRAINT
nn_system_user_1 NOT NULL
, system_user_group_id NUMBER CONSTRAINT
nn_system_user_2 NOT NULL
, system_user_type NUMBER CONSTRAINT
nn_system_user_3 NOT NULL
, last_name VARCHAR2(20)
, first_name VARCHAR2(20)
, middle_initial VARCHAR2(1)
, created_by NUMBER CONSTRAINT
nn_system_user_4 NOT NULL
, creation_date DATE CONSTRAINT
nn_system_user_5 NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_system_user_6 NOT NULL
, last_update_date DATE CONSTRAINT
nn_system_user_7 NOT NULL);
CREATE SEQUENCE system_user_s1 START WITH 1000;
INSERT INTO system_user
VALUES (
1,'SYSADMIN',1,1,1,NULL,NULL,1,SYSDATE,1,SYSDATE);
ALTER TABLE system_user ADD CONSTRAINT
fk_system_user_1 FOREIGN KEY(created_by)
REFERENCES system_user(system_user_id);
ALTER TABLE system_user ADD CONSTRAINT
fk_system_user_2 FOREIGN KEY(last_updated_by)
REFERENCES system_user(system_user_id);
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'COMMON_LOOKUP') LOOP
EXECUTE IMMEDIATE 'DROP TABLE common_lookup
CASCADE CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'COMMON_LOOKUP_S1')
LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE
common_lookup_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create COMMON_LOOKUP table and sequence and seed
data.
-- ------------------------------------------------------------------
CREATE TABLE common_lookup
( common_lookup_id NUMBER CONSTRAINT
pk_common_lookup PRIMARY KEY
, common_lookup_table VARCHAR2(30) CONSTRAINT
nn_common_lookup_1 NOT NULL
, common_lookup_column VARCHAR2(30)
CONSTRAINT nn_common_lookup_2 NOT NULL
, common_lookup_type VARCHAR2(30) CONSTRAINT
nn_common_lookup_3 NOT NULL
, common_lookup_code VARCHAR2(8)
, common_lookup_meaning VARCHAR2(255)
CONSTRAINT nn_common_lookup_4 NOT NULL
, created_by NUMBER CONSTRAINT
nn_common_lookup_5 NOT NULL
, creation_date DATE CONSTRAINT
nn_common_lookup_6 NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_common_lookup_7 NOT NULL
, last_update_date DATE CONSTRAINT
nn_common_lookup_8 NOT NULL
, CONSTRAINT fk_common_lookup_1 FOREIGN
KEY(created_by)
REFERENCES system_user(system_user_id)
, CONSTRAINT fk_common_lookup_2 FOREIGN
KEY(last_updated_by)
REFERENCES system_user(system_user_id));
CREATE INDEX common_lookup_n1
ON common_lookup(common_lookup_table);
CREATE UNIQUE INDEX common_lookup_u2
ON
common_lookup(common_lookup_table,common_lookup_colum
n,common_lookup_type);
CREATE SEQUENCE common_lookup_s1 START WITH 1000;
-- ------------------------------------------------------------------
-- Insert Common Lookups.
-- ------------------------------------------------------------------
SELECT 'INSERT COMMON_LOOKUP' AS "Section Header"
FROM dual;
INSERT INTO common_lookup VALUES
(
1,'SYSTEM_USER','SYSTEM_USER_TYPE','SYSTEM_ADMI
N',NULL,'System Administrator'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'SYSTEM_USER','SYSTEM_USER
_TYPE','DBA',NULL,'Database Administrator'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'CONTACT','CONTACT_TYPE','E
MPLOYEE',NULL,'Employee'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'CONTACT','CONTACT_TYPE','C
USTOMER',NULL,'Customer'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'MEMBER','MEMBER_TYPE','IND
IVIDUAL',NULL,'Individual Membership'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'MEMBER','MEMBER_TYPE','GR
OUP',NULL,'Group Membership'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'MEMBER','CREDIT_CARD_TYPE
','DISCOVER_CARD',NULL,'Discover Card'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'MEMBER','CREDIT_CARD_TYPE
','MASTER_CARD',NULL,'Master Card'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'MEMBER','CREDIT_CARD_TYPE
','VISA_CARD',NULL,'VISA Card'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'ADDRESS','ADDRESS_TYPE','H
OME',NULL,'Home'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'ADDRESS','ADDRESS_TYPE','W
ORK',NULL,'Work'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'TELEPHONE','TELEPHONE_TYP
E','HOME',NULL,'Home'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'TELEPHONE','TELEPHONE_TYP
E','WORK',NULL,'Work'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'ITEM','ITEM_TYPE','DVD_FULL
_SCREEN',NULL,'DVD: Full Screen'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'ITEM','ITEM_TYPE','DVD_WIDE
_SCREEN',NULL,'DVD: Wide Screen'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'ITEM','ITEM_TYPE','GAMECUBE
',NULL,'Nintendo GameCube'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'ITEM','ITEM_TYPE','PLAYSTATI
ON2',NULL,'PlayStation2'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'ITEM','ITEM_TYPE','XBOX',NUL
L,'XBOX'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'ITEM','ITEM_TYPE','VHS_SINGL
E_TAPE',NULL,'VHS: Single Tape'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'ITEM','ITEM_TYPE','VHS_DOUB
LE_TAPE',NULL,'VHS: Double Tape'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'ITEM','ITEM_RATING_AGENCY'
,'MPAA','MPAA','Motion Picture Association of America'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
(
common_lookup_s1.nextval,'ITEM','ITEM_RATING_AGENCY'
,'ESRB','ESRB','Entertainment Software Rating Board'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','MPAA
G','G','G - General Audiences: All ages admitted.'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','MPAA
PG','PG','PG - Parental guidance suggested: Some material may
not be suitable for children.'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','MPAA
PG-13','PG-13','PG-13 - Parents strongly cautioned: Some
material may be inappropriate for children under 13.'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','MPAA
R','R','R - Restricted: Under 17 requires accompanying parent or
adult guardian.'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','MPAA
NC-17','NC-17','NC-17 - No one 17 and under admitted.'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','MPAA
NR','NR','NR - Not Rated.'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB
EC','ED','EC - Early Childhood: Contains content that may be
suitable for ages 3 and older. Contains no material that parents
would find inappropriate.'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB
E','E','E - Everyone: Contains content that may be suitable for
ages 6 and older. Titles in this category may contain minimal
cartoon, fantasy or mild violence and/or infrequent use of mild
language.'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB
E10+','E10+','E10+ - Everyone 10+: Contains content that may
be suitable for ages 10 and older. Titles in this category may
contain more cartoon, fantasy or mild violence, mild language,
minimal and/or infrequent blood and/or minimal suggestive
themes.'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB
T','T','T - Teen: Contains content that may be suitable for ages
13 and older. Titles in this category may contain violence,
suggestive themes, crude humor, minimal blood, simulated
gambling, and/or infrequent use of strong language.'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB
M','M','M - Mature: Contains content that may be suitable for
ages 17 and older. Titles in this category may contain intense
violence, blood and gore, sexual content and/or strong
language.'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB
AO','AO','AO - Adult Only: Contains content that is suitable
only for adults. Titles in this category may include prolonged
scenes of intense violence and/or graphic sexual content and
nudity.'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup VALUES
( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB
RP','RP','RP - Rating Pending: Product has been submitted to
the ESRB and is awaiting final rating (prior to product release).'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO COMMON_LOOKUP VALUES
( common_lookup_s1.nextval, 'TRANSACTION',
'TRANSACTION_TYPE', 'DEBIT', 'DB', 'Debit', 1, SYSDATE,
1, SYSDATE);
INSERT INTO COMMON_LOOKUP VALUES
( common_lookup_s1.nextval, 'TRANSACTION',
'TRANSACTION_TYPE', 'CREDIT', 'CR', 'Credit', 1,
SYSDATE, 1, SYSDATE);
INSERT INTO COMMON_LOOKUP VALUES
( common_lookup_s1.nextval, 'TRANSACTION',
'PAYMENT_METHOD_TYPE', 'DISCOVER_CARD', '',
'Discover Card', 1, SYSDATE, 1, SYSDATE);
INSERT INTO COMMON_LOOKUP VALUES
( common_lookup_s1.nextval, 'TRANSACTION',
'PAYMENT_METHOD_TYPE', 'VISA_CARD', '', 'Visa Card',
1, SYSDATE, 1, SYSDATE);
INSERT INTO COMMON_LOOKUP VALUES
( common_lookup_s1.nextval, 'TRANSACTION',
'PAYMENT_METHOD_TYPE', 'MASTER_CARD', '', 'Master
Card', 1, SYSDATE, 1, SYSDATE);
INSERT INTO COMMON_LOOKUP VALUES
( common_lookup_s1.nextval, 'TRANSACTION',
'PAYMENT_METHOD_TYPE', 'CASH', '', 'Cash', 1, SYSDATE,
1, SYSDATE);
INSERT INTO COMMON_LOOKUP VALUES
( common_lookup_s1.nextval, 'RENTAL_ITEM',
'RENTAL_ITEM_TYPE', '1-DAY RENTAL', '', '1-Day Rental',
1, SYSDATE, 1, SYSDATE);
INSERT INTO COMMON_LOOKUP VALUES
( common_lookup_s1.nextval, 'RENTAL_ITEM',
'RENTAL_ITEM_TYPE', '3-DAY RENTAL', '', '3-Day Rental',
1, SYSDATE, 1, SYSDATE);
INSERT INTO COMMON_LOOKUP VALUES
( common_lookup_s1.nextval, 'RENTAL_ITEM',
'RENTAL_ITEM_TYPE', '5-DAY RENTAL', '', '5-Day Rental',
1, SYSDATE, 1, SYSDATE);
-- Format and query output.
--COLUMN common_lookup_id FORMAT 9999 HEADING
"Lookup|ID #"
--COLUMN common_lookup_table FORMAT A18 HEADING
"Lookup|Table"
--COLUMN common_lookup_column FORMAT A20
HEADING "Lookup|Column"
--COLUMN common_lookup_type FORMAT A18 HEADING
"Lookup|Type"
--COLUMN common_lookup_code FORMAT A8 HEADING
"Lookup|Code"
--SELECT common_lookup_id
--, common_lookup_table
--, common_lookup_column
--, common_lookup_type
--, common_lookup_code
--FROM common_lookup;
ALTER TABLE system_user ADD CONSTRAINT
fk_system_user_3 FOREIGN KEY(system_user_type)
REFERENCES common_lookup(common_lookup_id);
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'MEMBER') LOOP
EXECUTE IMMEDIATE 'DROP TABLE member CASCADE
CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'MEMBER_S1') LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE member_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create MEMBER table and sequence and seed data.
-- ------------------------------------------------------------------
CREATE TABLE member
( member_id NUMBER CONSTRAINT
pk_member PRIMARY KEY
, member_type NUMBER CONSTRAINT
nn_member_1 NOT NULL
, account_number VARCHAR2(10) CONSTRAINT
nn_member_2 NOT NULL
, credit_card_number VARCHAR2(19) CONSTRAINT
nn_member_3 NOT NULL
, credit_card_type NUMBER CONSTRAINT
nn_member_4 NOT NULL
, created_by NUMBER CONSTRAINT
nn_member_5 NOT NULL
, creation_date DATE CONSTRAINT
nn_member_6 NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_member_7 NOT NULL
, last_update_date DATE CONSTRAINT
nn_member_8 NOT NULL
, CONSTRAINT fk_member_1 FOREIGN
KEY(member_type)
REFERENCES common_lookup(common_lookup_id)
, CONSTRAINT fk_member_2 FOREIGN
KEY(credit_card_type)
REFERENCES common_lookup(common_lookup_id)
, CONSTRAINT fk_member_3 FOREIGN
KEY(created_by)
REFERENCES system_user(system_user_id)
, CONSTRAINT fk_member_4 FOREIGN
KEY(last_updated_by)
REFERENCES system_user(system_user_id));
CREATE SEQUENCE member_s1 START WITH 1000;
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'CONTACT') LOOP
EXECUTE IMMEDIATE 'DROP TABLE contact CASCADE
CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'CONTACT_S1') LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE contact_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create CONTACT table and sequence and seed data.
-- ------------------------------------------------------------------
CREATE TABLE contact
( contact_id NUMBER CONSTRAINT
pk_contact PRIMARY KEY
, member_id NUMBER CONSTRAINT
nn_contact_1 NOT NULL
, contact_type NUMBER CONSTRAINT
nn_contact_2 NOT NULL
, last_name VARCHAR2(20) CONSTRAINT
nn_contact_3 NOT NULL
, first_name VARCHAR2(20) CONSTRAINT
nn_contact_4 NOT NULL
, middle_name VARCHAR2(20)
, created_by NUMBER CONSTRAINT
nn_contact_5 NOT NULL
, creation_date DATE CONSTRAINT
nn_contact_6 NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_contact_7 NOT NULL
, last_update_date DATE CONSTRAINT
nn_contact_8 NOT NULL
, CONSTRAINT fk_contact_1 FOREIGN
KEY(member_id)
REFERENCES member(member_id)
, CONSTRAINT fk_contact_2 FOREIGN
KEY(contact_type)
REFERENCES common_lookup(common_lookup_id)
, CONSTRAINT fk_contact_3 FOREIGN
KEY(created_by)
REFERENCES system_user(system_user_id)
, CONSTRAINT fk_contact_4 FOREIGN
KEY(last_updated_by)
REFERENCES system_user(system_user_id));
CREATE INDEX contact_n1 ON contact(member_id);
CREATE SEQUENCE contact_s1 START WITH 1000;
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'ADDRESS') LOOP
EXECUTE IMMEDIATE 'DROP TABLE address CASCADE
CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'ADDRESS_S1') LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE address_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create ADDRESS table and sequence and seed data.
-- ------------------------------------------------------------------
CREATE TABLE address
( address_id NUMBER CONSTRAINT
pk_address PRIMARY KEY
, contact_id NUMBER CONSTRAINT
nn_address_1 NOT NULL
, address_type NUMBER CONSTRAINT
nn_address_2 NOT NULL
, city VARCHAR2(30) CONSTRAINT
nn_address_3 NOT NULL
, state_province VARCHAR2(30) CONSTRAINT
nn_address_4 NOT NULL
, postal_code VARCHAR2(20) CONSTRAINT
nn_address_5 NOT NULL
, created_by NUMBER CONSTRAINT
nn_address_6 NOT NULL
, creation_date DATE CONSTRAINT
nn_address_7 NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_address_8 NOT NULL
, last_update_date DATE CONSTRAINT
nn_address_9 NOT NULL
, CONSTRAINT fk_address_1 FOREIGN
KEY(contact_id)
REFERENCES contact(contact_id)
, CONSTRAINT fk_address_2 FOREIGN
KEY(address_type)
REFERENCES common_lookup(common_lookup_id)
, CONSTRAINT fk_address_3 FOREIGN
KEY(created_by)
REFERENCES system_user(system_user_id)
, CONSTRAINT fk_address_4 FOREIGN
KEY(last_updated_by)
REFERENCES system_user(system_user_id));
CREATE INDEX address_n1 ON address(contact_id);
CREATE SEQUENCE address_s1 START WITH 1000;
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'STREET_ADDRESS') LOOP
EXECUTE IMMEDIATE 'DROP TABLE street_address
CASCADE CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'STREET_ADDRESS_S1')
LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE
street_address_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create STREET_ADDRESS table and sequence and seed data.
-- ------------------------------------------------------------------
CREATE TABLE street_address
( street_address_id NUMBER CONSTRAINT
pk_st_address PRIMARY KEY
, address_id NUMBER CONSTRAINT
nn_st_address_1 NOT NULL
, line_number NUMBER CONSTRAINT
nn_st_address_2 NOT NULL
, street_address VARCHAR2(30) CONSTRAINT
nn_st_address_3 NOT NULL
, created_by NUMBER CONSTRAINT
nn_st_address_4 NOT NULL
, creation_date DATE CONSTRAINT
nn_st_address_5 NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_st_address_6 NOT NULL
, last_update_date DATE CONSTRAINT
nn_st_address_7 NOT NULL
, CONSTRAINT fk_st_address_1 FOREIGN
KEY(address_id)
REFERENCES address(address_id)
, CONSTRAINT fk_st_address_2 FOREIGN
KEY(created_by)
REFERENCES system_user(system_user_id)
, CONSTRAINT fk_st_address_3 FOREIGN
KEY(last_updated_by)
REFERENCES system_user(system_user_id));
CREATE SEQUENCE street_address_s1 START WITH 1000;
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'TELEPHONE') LOOP
EXECUTE IMMEDIATE 'DROP TABLE telephone
CASCADE CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'TELEPHONE_S1') LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE telephone_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create TELEPHONE table and sequence and seed data.
-- ------------------------------------------------------------------
CREATE TABLE telephone
( telephone_id NUMBER CONSTRAINT
pk_telephone PRIMARY KEY
, contact_id NUMBER CONSTRAINT
nn_telephone_1 NOT NULL
, address_id NUMBER CONSTRAINT
nn_telephone_2 NOT NULL
, telephone_type NUMBER CONSTRAINT
nn_telephone_3 NOT NULL
, country_code VARCHAR2(3) CONSTRAINT
nn_telephone_4 NOT NULL
, area_code VARCHAR2(6) CONSTRAINT
nn_telephone_5 NOT NULL
, telephone_number VARCHAR2(10) CONSTRAINT
nn_telephone_6 NOT NULL
, created_by NUMBER CONSTRAINT
nn_telephone_7 NOT NULL
, creation_date DATE CONSTRAINT
nn_telephone_8 NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_telephone_9 NOT NULL
, last_update_date DATE CONSTRAINT
nn_telephone_10 NOT NULL
, CONSTRAINT fk_telephone_1 FOREIGN
KEY(contact_id)
REFERENCES contact(contact_id)
, CONSTRAINT fk_telephone_2 FOREIGN
KEY(telephone_type)
REFERENCES common_lookup(common_lookup_id)
, CONSTRAINT fk_telephone_3 FOREIGN
KEY(created_by)
REFERENCES system_user(system_user_id)
, CONSTRAINT fk_telephone_4 FOREIGN
KEY(last_updated_by)
REFERENCES system_user(system_user_id));
CREATE INDEX telephone_n1 ON
telephone(contact_id,address_id);
CREATE INDEX telephone_n2 ON telephone(address_id);
CREATE SEQUENCE telephone_s1 START WITH 1000;
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'RENTAL') LOOP
EXECUTE IMMEDIATE 'DROP TABLE rental CASCADE
CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'RENTAL_S1') LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE rental_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create RENTAL table and sequence and seed data.
-- ------------------------------------------------------------------
CREATE TABLE rental
( rental_id NUMBER CONSTRAINT pk_rental
PRIMARY KEY
, customer_id NUMBER CONSTRAINT
nn_rental_1 NOT NULL
, check_out_date DATE CONSTRAINT
nn_rental_2 NOT NULL
, return_date DATE CONSTRAINT
nn_rental_3 NOT NULL
, created_by NUMBER CONSTRAINT
nn_rental_4 NOT NULL
, creation_date DATE CONSTRAINT
nn_rental_5 NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_rental_6 NOT NULL
, last_update_date DATE CONSTRAINT
nn_rental_7 NOT NULL
, CONSTRAINT fk_rental_1 FOREIGN
KEY(customer_id)
REFERENCES contact(contact_id)
, CONSTRAINT fk_rental_2 FOREIGN
KEY(created_by)
REFERENCES system_user(system_user_id)
, CONSTRAINT fk_rental_3 FOREIGN
KEY(last_updated_by)
REFERENCES system_user(system_user_id));
CREATE SEQUENCE rental_s1 START WITH 1000;
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'ITEM') LOOP
EXECUTE IMMEDIATE 'DROP TABLE item CASCADE
CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'ITEM_S1') LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE item_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create ITEM table and sequence and seed data.
-- ------------------------------------------------------------------
CREATE TABLE item
( item_id NUMBER CONSTRAINT pk_item
PRIMARY KEY
, item_barcode VARCHAR2(20) CONSTRAINT
nn_item_1 NOT NULL
, item_type NUMBER CONSTRAINT
nn_item_2 NOT NULL
, item_title VARCHAR2(60) CONSTRAINT
nn_item_3 NOT NULL
, item_subtitle VARCHAR2(60)
, item_desc CLOB CONSTRAINT nn_item_4
NOT NULL
, item_photo BFILE
, item_rating VARCHAR2(8) CONSTRAINT
nn_item_5 NOT NULL
, item_rating_agency VARCHAR2(4) CONSTRAINT
nn_item_6 NOT NULL
, item_release_date DATE CONSTRAINT
nn_item_7 NOT NULL
, created_by NUMBER CONSTRAINT
nn_item_8 NOT NULL
, creation_date DATE CONSTRAINT nn_item_9
NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_item_10 NOT NULL
, last_update_date DATE CONSTRAINT
nn_item_11 NOT NULL
, CONSTRAINT fk_item_1 FOREIGN
KEY(item_type)
REFERENCES common_lookup(common_lookup_id)
, CONSTRAINT fk_item_2 FOREIGN
KEY(created_by)
REFERENCES system_user(system_user_id)
, CONSTRAINT fk_item_3 FOREIGN
KEY(last_updated_by)
REFERENCES system_user(system_user_id));
CREATE SEQUENCE item_s1 START WITH 1000;
-- ------------------------------------------------------------------
-- Create ITEM table triggers for content reference column.
-- ------------------------------------------------------------------
-- Check for valid rating in COMMON_LOOKUP table.
CREATE OR REPLACE TRIGGER item_t1
BEFORE INSERT OR UPDATE OF item_rating ON item
FOR EACH ROW
DECLARE
-- Declare guard variable.
found BOOLEAN := FALSE;
-- Declare dynamic cursor.
CURSOR get_ratings
( code VARCHAR2 ) IS
SELECT common_lookup_code
FROM common_lookup
WHERE common_lookup_table = 'ITEM'
AND common_lookup_column = 'ITEM_RATING'
AND common_lookup_code = code;
-- Define and set user-defined error.
bad_rating EXCEPTION;
PRAGMA EXCEPTION_INIT(bad_rating,-20101);
BEGIN
-- Check for valid rating.
FOR i IN get_ratings(:new.item_rating) LOOP
found := TRUE;
END LOOP;
-- Raise exception for invalid rating.
IF NOT found THEN
RAISE_APPLICATION_ERROR(-20101,'Rating Value not
defined in COMMON_LOOKUP table.');
END IF;
END item_t1;
/
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'RENTAL_ITEM') LOOP
EXECUTE IMMEDIATE 'DROP TABLE rental_item
CASCADE CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'RENTAL_ITEM_S1')
LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE
rental_item_s1';
END LOOP;
END;
/
-- Check for valid rating agency in COMMON_LOOKUP table.
CREATE OR REPLACE TRIGGER item_t1
BEFORE INSERT OR UPDATE OF item_rating_agency ON
item
FOR EACH ROW
DECLARE
-- Declare guard variable.
found BOOLEAN := FALSE;
-- Declare dynamic cursor.
CURSOR get_ratings
( agency VARCHAR2 ) IS
SELECT common_lookup_code
FROM common_lookup
WHERE common_lookup_table = 'ITEM'
AND common_lookup_column =
'ITEM_RATING_AGENCY'
AND common_lookup_code = agency;
-- Define and set user-defined error.
bad_rating EXCEPTION;
PRAGMA EXCEPTION_INIT(bad_rating,-20102);
BEGIN
-- Check for valid rating.
FOR i IN get_ratings(:new.item_rating_agency) LOOP
found := TRUE;
END LOOP;
-- Raise exception for invalid rating.
IF NOT found THEN
RAISE_APPLICATION_ERROR(-20102,'Rating Agency
Value not defined in COMMON_LOOKUP table.');
END IF;
END item_t1;
/
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'RENTAL_ITEM') LOOP
EXECUTE IMMEDIATE 'DROP TABLE rental_item
CASCADE CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'RENTAL_ITEM_S1')
LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE
rental_item_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create RENTAL_ITEM table and sequence and seed data.
-- ------------------------------------------------------------------
CREATE TABLE rental_item
( rental_item_id NUMBER CONSTRAINT
pk_rental_item PRIMARY KEY
, rental_id NUMBER CONSTRAINT
nn_rental_item_1 NOT NULL
, item_id NUMBER CONSTRAINT
nn_rental_item_2 NOT NULL
, rental_item_price NUMBER CONSTRAINT
nn_rental_item_3 NOT NULL
, rental_item_type NUMBER CONSTRAINT
nn_rental_item_4 NOT NULL
, created_by NUMBER CONSTRAINT
nn_rental_item_5 NOT NULL
, creation_date DATE CONSTRAINT
nn_rental_item_6 NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_rental_item_7 NOT NULL
, last_update_date DATE CONSTRAINT
nn_rental_item_8 NOT NULL
, CONSTRAINT fk_rental_item_1 FOREIGN
KEY(rental_id)
REFERENCES rental(rental_id)
, CONSTRAINT fk_rental_item_2 FOREIGN
KEY(item_id)
REFERENCES item(item_id)
, CONSTRAINT fk_rental_item_3 FOREIGN
KEY(created_by)
REFERENCES system_user(system_user_id)
, CONSTRAINT fk_rental_item_4 FOREIGN
KEY(last_updated_by)
REFERENCES system_user(system_user_id));
CREATE SEQUENCE rental_item_s1 START WITH 1000;
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'PRICE') LOOP
EXECUTE IMMEDIATE 'DROP TABLE price CASCADE
CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'PRICE_S1') LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE price_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create PRICE table and sequence and seed data.
-- ------------------------------------------------------------------
CREATE TABLE price
( price_id NUMBER CONSTRAINT pk_price
PRIMARY KEY
, item_id NUMBER CONSTRAINT
nn_price_1 NOT NULL
, price_type NUMBER CONSTRAINT
nn_price_2 NOT NULL
, active_flag VARCHAR2(1) CONSTRAINT
nn_price_3 NOT NULL
, amount NUMBER CONSTRAINT
nn_price_4 NOT NULL
, start_date DATE CONSTRAINT nn_price_5
NOT NULL
, end_date DATE
, created_by NUMBER CONSTRAINT
nn_price_6 NOT NULL
, creation_date DATE CONSTRAINT
nn_price_7 NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_price_8 NOT NULL
, last_update_date DATE CONSTRAINT
nn_price_9 NOT NULL
, CONSTRAINT fk_price_1 FOREIGN
KEY(item_id)
REFERENCES item(item_id)
, CONSTRAINT fk_price_2 FOREIGN
KEY(price_type)
REFERENCES common_lookup(common_lookup_id)
, CONSTRAINT fk_price_3 FOREIGN
KEY(created_by)
REFERENCES system_user(system_user_id)
, CONSTRAINT fk_price_4 FOREIGN
KEY(last_updated_by)
REFERENCES system_user(system_user_id));
CREATE SEQUENCE price_s1 START WITH 1000;
-- ------------------------------------------------------------------
-- Seed PRICE data in COMMON_LOOKUP table.
-- ------------------------------------------------------------------
INSERT INTO common_lookup
VALUES
(
common_lookup_s1.nextval,'PRICE','ACTIVE_FLAG','YES','Y',
'Yes'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup
VALUES
(
common_lookup_s1.nextval,'PRICE','ACTIVE_FLAG','NO','N','
Yes'
, 1, SYSDATE, 1, SYSDATE);
INSERT INTO common_lookup
( common_lookup_id -- 1
, common_lookup_table -- 2
, common_lookup_column -- 3
, common_lookup_type -- 4
, common_lookup_code -- 5
, common_lookup_meaning -- 6
, created_by -- 7
, creation_date -- 8
, last_updated_by -- 9
, last_update_date) -- 10
SELECT common_lookup_s1.nextval -- 1
(id)
, 'PRICE' -- 2 (table)
, 'AMOUNT' -- 3 (column)
, il.type -- 4 (type)
, TO_CHAR(il.fabricated) -- 5 (code)
, il.meaning -- 6 (meaning)
, 1 -- 7 (c_id)
, SYSDATE -- 8 (c_date)
, 1 -- 9 (u_id)
, SYSDATE -- 10 (u_date)
FROM dual CROSS JOIN (SELECT 'New' AS status
, 1 AS fabricated
, '1-DAY RENTAL' type
, '1-Day Rental' meaning FROM dual
UNION ALL
SELECT 'New' AS type
, 3 AS fabricated
, '3-DAY RENTAL' type
, '3-Day Rental' meaning FROM dual
UNION ALL
SELECT 'New' AS type
, 5 AS fabricated
, '5-DAY RENTAL' type
, '5-Day Rental' meaning FROM dual) il;
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'TRANSACTION') LOOP
EXECUTE IMMEDIATE 'DROP TABLE transaction
CASCADE CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'TRANSACTION_S1')
LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE
transaction_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create TRANSACTION table and sequence and seed data.
-- ------------------------------------------------------------------
CREATE TABLE transaction
( transaction_id NUMBER CONSTRAINT
pk_transaction PRIMARY KEY
, transaction_account VARCHAR2(20) CONSTRAINT
nn_transaction_1 NOT NULL
, transaction_type NUMBER CONSTRAINT
nn_transaction_2 NOT NULL
, transaction_date DATE CONSTRAINT
nn_transaction_3 NOT NULL
, transaction_amount NUMBER CONSTRAINT
nn_transaction_4 NOT NULL
, rental_id NUMBER CONSTRAINT
nn_transaction_5 NOT NULL
, payment_method NUMBER CONSTRAINT
nn_transaction_6 NOT NULL
, payment_account_number VARCHAR2(20)
CONSTRAINT nn_transaction_7 NOT NULL
, created_by NUMBER CONSTRAINT
nn_transaction_8 NOT NULL
, creation_date DATE CONSTRAINT
nn_transaction_9 NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_transaction_10 NOT NULL
, last_update_date DATE CONSTRAINT
nn_transaction_11 NOT NULL
, CONSTRAINT fk_transaction_1 FOREIGN
KEY(rental_id)
REFERENCES rental(rental_id)
, CONSTRAINT fk_transaction_2 FOREIGN
KEY(transaction_type)
REFERENCES common_lookup(common_lookup_id)
, CONSTRAINT fk_transaction_3 FOREIGN
KEY(created_by)
REFERENCES system_user(system_user_id)
, CONSTRAINT fk_transaction_4 FOREIGN
KEY(last_updated_by)
REFERENCES system_user(system_user_id));
CREATE SEQUENCE transaction_s1 START WITH 1000;
-- Conditionally drop objects.
BEGIN
FOR i IN (SELECT null
FROM user_tables
WHERE table_name = 'CALENDAR') LOOP
EXECUTE IMMEDIATE 'DROP TABLE calendar CASCADE
CONSTRAINTS';
END LOOP;
FOR i IN (SELECT null
FROM user_sequences
WHERE sequence_name = 'CALENDAR_S1') LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE calendar_s1';
END LOOP;
END;
/
-- ------------------------------------------------------------------
-- Create CALENDAR table and sequence and seed data.
-- ------------------------------------------------------------------
CREATE TABLE calendar
( calendar_id NUMBER CONSTRAINT
pk_calendar PRIMARY KEY
, calendar_month_name VARCHAR2(3) CONSTRAINT
nn_calendar_1 NOT NULL
, calendar_full_month_name VARCHAR2(9) CONSTRAINT
nn_calendar_2 NOT NULL
, start_date DATE CONSTRAINT
nn_calendar_3 NOT NULL
, end_date DATE CONSTRAINT
nn_calendar_4 NOT NULL
, created_by NUMBER CONSTRAINT
nn_calendar_5 NOT NULL
, creation_date DATE CONSTRAINT
nn_calendar_6 NOT NULL
, last_updated_by NUMBER CONSTRAINT
nn_calendar_7 NOT NULL
, last_update_date DATE CONSTRAINT
nn_calendar_8 NOT NULL
, CONSTRAINT fk_calendar_1 FOREIGN
KEY(created_by)
REFERENCES system_user(system_user_id)
, CONSTRAINT fk_calendar_2 FOREIGN
KEY(last_updated_by)
REFERENCES system_user(system_user_id));
CREATE SEQUENCE calendar_s1 START WITH 1000;
-- Seed the Calendar table.
DECLARE
-- Define local variables.
start_date DATE;
end_date DATE;
-- Define local array types.
TYPE number_list IS TABLE OF NUMBER;
TYPE month_list IS TABLE OF VARCHAR2(3);
TYPE name_list IS TABLE OF VARCHAR2(9);
-- Define and initialize array for month ending date.
end_day NUMBER_LIST := number_list(31,28,31
,30,31,30
,31,31,30
,31,30,31);
-- Define and initial short and long month names.
months MONTH_LIST := month_list('JAN','FEB','MAR'
,'APR','MAY','JUN'
,'JUL','AUG','SEP'
,'OCT','NOV','DEC');
month_names NAME_LIST :=
name_list('January','February','March'
,'April','May','June'
,'July','August','September'
,'October','November','December');
-- Define and initialize years.
years NUMBER_LIST :=
number_list(1996,1997,1998,1999,2000
,2001,2002,2003,2004,2005
,2006,2007,2008,2009,2010
,2011,2012,2013,2014,2015
,2016,2017,2018,2019,2020);
BEGIN
-- Loop through years and then months.
FOR i IN 1..years.COUNT LOOP
FOR j IN 1..months.COUNT LOOP
-- Set month starting date.
start_date := TO_DATE('01'||months(j)||years(i),'DD-MON-
YYYY');
-- Check, modify leap year February, and set month ending
date.
IF ((MOD(years(i) , 4) = 0) AND (j = 2)) THEN
end_date := TO_DATE((end_day(j) + 1)||'-'||months(j)||'-
'||years(i),'DD-MON-YYYY');
ELSE
end_date := TO_DATE((end_day(j))||'-'||months(j)||'-
'||years(i),'DD-MON-YYYY');
END IF;
-- Insert month into calendar.
INSERT INTO calendar
VALUES
( calendar_s1.nextval
, months(j)
, month_names(j)
, start_date
, end_date
, 1,SYSDATE,1,SYSDATE);
END LOOP;
END LOOP;
END;
/
/*
-- ------------------------------------------------------------------
-- Insert DBA values in SYSTEM_USER table.
-- ------------------------------------------------------------------ */
SELECT 'INSERT DBAs IN SYSTEM_USER' AS "Section
Header" FROM dual;
INSERT
INTO system_user
( system_user_id
, system_user_name
, system_user_group_id
, system_user_type
, last_name
, first_name
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( 2,'DBA', 2, 1,'Adams','Samuel', 1, SYSDATE, 1, SYSDATE);
INSERT
INTO system_user
( system_user_id
, system_user_name
, system_user_group_id
, system_user_type
, last_name
, first_name
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( 3,'DBA', 2, 1,'Henry','Patrick', 1, SYSDATE, 1, SYSDATE);
INSERT
INTO system_user
( system_user_id
, system_user_name
, system_user_group_id
, system_user_type
, last_name
, first_name
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( 4,'DBA', 2, 1,'Puri','Manmohan', 1, SYSDATE, 1, SYSDATE);
INSERT
INTO system_user
( system_user_id
, system_user_name
, system_user_group_id
, system_user_type
, last_name
, first_name
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( 5,'DBA', 2, 1,'Fullerton','Gail', 1, SYSDATE, 1, SYSDATE);
-- ------------------------------------------------------------------
-- This seeds rows in a dependency chain, including the
MEMBER, CONTACT
-- ADDRESS, and TELEPHONE tables.
-- ------------------------------------------------------------------
-- Insert record set #1.
-- ------------------------------------------------------------------
SELECT 'INSERT MEMBER, CONTACT, ADDRESS, ETC' AS
"Section Header" FROM dual;
INSERT INTO member VALUES
( member_s1.nextval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'MEMBER'
AND common_lookup_column = 'MEMBER_TYPE'
AND common_lookup_type = 'GROUP')
,'B293-71445'
,'1111-2222-3333-4444'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'MEMBER'
AND common_lookup_column = 'CREDIT_CARD_TYPE'
AND common_lookup_type = 'DISCOVER_CARD')
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO contact
( contact_id
, member_id
, contact_type
, first_name
, middle_name
, last_name
, created_by
, creation_date
, last_updated_by
, last_update_date )
VALUES
( contact_s1.nextval
, member_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'CONTACT'
AND common_lookup_column = 'CONTACT_TYPE'
AND common_lookup_type = 'CUSTOMER')
,'Randi','','Winn'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO address VALUES
( address_s1.nextval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'ADDRESS'
AND common_lookup_column = 'ADDRESS_TYPE'
AND common_lookup_type = 'HOME')
,'San Jose','CA','95192'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO street_address VALUES
( street_address_s1.nextval
, address_s1.currval
, 1
,'10 El Camino Real'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO telephone VALUES
( telephone_s1.nextval
, address_s1.currval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'TELEPHONE'
AND common_lookup_column = 'TELEPHONE_TYPE'
AND common_lookup_type = 'HOME')
,'USA','408','111-1111'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO contact
( contact_id
, member_id
, contact_type
, first_name
, middle_name
, last_name
, created_by
, creation_date
, last_updated_by
, last_update_date )
VALUES
( contact_s1.nextval
, member_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'CONTACT'
AND common_lookup_column = 'CONTACT_TYPE'
AND common_lookup_type = 'CUSTOMER')
,'Brian','','Winn'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO address VALUES
( address_s1.nextval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'ADDRESS'
AND common_lookup_column = 'ADDRESS_TYPE'
AND common_lookup_type = 'HOME')
,'San Jose','CA','95192'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO street_address VALUES
( street_address_s1.nextval
, address_s1.currval
, 1
,'10 El Camino Real'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO telephone VALUES
( telephone_s1.nextval
, address_s1.currval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'TELEPHONE'
AND common_lookup_column = 'TELEPHONE_TYPE'
AND common_lookup_type = 'HOME')
,'USA','408','111-1111'
, 2, SYSDATE, 2, SYSDATE);
-- ------------------------------------------------------------------
-- Insert record set #2.
-- ------------------------------------------------------------------
INSERT INTO member VALUES
( member_s1.nextval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'MEMBER'
AND common_lookup_column = 'MEMBER_TYPE'
AND common_lookup_type = 'GROUP')
,'B293-71446'
,'2222-3333-4444-5555'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'MEMBER'
AND common_lookup_column = 'CREDIT_CARD_TYPE'
AND common_lookup_type = 'DISCOVER_CARD')
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO contact
( contact_id
, member_id
, contact_type
, first_name
, middle_name
, last_name
, created_by
, creation_date
, last_updated_by
, last_update_date )
VALUES
( contact_s1.nextval
, member_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'CONTACT'
AND common_lookup_column = 'CONTACT_TYPE'
AND common_lookup_type = 'CUSTOMER')
,'Oscar','','Vizquel'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO address VALUES
( address_s1.nextval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'ADDRESS'
AND common_lookup_column = 'ADDRESS_TYPE'
AND common_lookup_type = 'HOME')
,'San Jose','CA','95192'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO street_address VALUES
( street_address_s1.nextval
, address_s1.currval
, 1
,'12 El Camino Real'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO telephone VALUES
( telephone_s1.nextval
, address_s1.currval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'TELEPHONE'
AND common_lookup_column = 'TELEPHONE_TYPE'
AND common_lookup_type = 'HOME')
,'USA','408','222-2222'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO contact
( contact_id
, member_id
, contact_type
, first_name
, middle_name
, last_name
, created_by
, creation_date
, last_updated_by
, last_update_date )
VALUES
( contact_s1.nextval
, member_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'CONTACT'
AND common_lookup_column = 'CONTACT_TYPE'
AND common_lookup_type = 'CUSTOMER')
,'Doreen','','Vizquel'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO address VALUES
( address_s1.nextval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'ADDRESS'
AND common_lookup_column = 'ADDRESS_TYPE'
AND common_lookup_type = 'HOME')
,'San Jose','CA','95192'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO street_address VALUES
( street_address_s1.nextval
, address_s1.currval
, 1
,'12 El Camino Real'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO telephone VALUES
( telephone_s1.nextval
, address_s1.currval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'TELEPHONE'
AND common_lookup_column = 'TELEPHONE_TYPE'
AND common_lookup_type = 'HOME')
,'USA','408','222-2222'
, 2, SYSDATE, 2, SYSDATE);
-- ------------------------------------------------------------------
-- Insert record set #3.
-- ------------------------------------------------------------------
INSERT INTO member VALUES
( member_s1.nextval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'MEMBER'
AND common_lookup_column = 'MEMBER_TYPE'
AND common_lookup_type = 'GROUP')
,'B293-71447'
,'3333-4444-5555-6666'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'MEMBER'
AND common_lookup_column = 'CREDIT_CARD_TYPE'
AND common_lookup_type = 'DISCOVER_CARD')
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO contact
( contact_id
, member_id
, contact_type
, first_name
, middle_name
, last_name
, created_by
, creation_date
, last_updated_by
, last_update_date )
VALUES
( contact_s1.nextval
, member_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'CONTACT'
AND common_lookup_column = 'CONTACT_TYPE'
AND common_lookup_type = 'CUSTOMER')
,'Meaghan','','Sweeney'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO address VALUES
( address_s1.nextval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'ADDRESS'
AND common_lookup_column = 'ADDRESS_TYPE'
AND common_lookup_type = 'HOME')
,'San Jose','CA','95192'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO street_address VALUES
( street_address_s1.nextval
, address_s1.currval
, 1
,'14 El Camino Real'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO telephone VALUES
( telephone_s1.nextval
, address_s1.currval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'TELEPHONE'
AND common_lookup_column = 'TELEPHONE_TYPE'
AND common_lookup_type = 'HOME')
,'USA','408','333-3333'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO contact
( contact_id
, member_id
, contact_type
, first_name
, middle_name
, last_name
, created_by
, creation_date
, last_updated_by
, last_update_date )
VALUES
( contact_s1.nextval
, member_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'CONTACT'
AND common_lookup_column = 'CONTACT_TYPE'
AND common_lookup_type = 'CUSTOMER')
,'Matthew','','Sweeney'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO address VALUES
( address_s1.nextval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'ADDRESS'
AND common_lookup_column = 'ADDRESS_TYPE'
AND common_lookup_type = 'HOME')
,'San Jose','CA','95192'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO street_address VALUES
( street_address_s1.nextval
, address_s1.currval
, 1
,'14 El Camino Real'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO telephone VALUES
( telephone_s1.nextval
, address_s1.currval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'TELEPHONE'
AND common_lookup_column = 'TELEPHONE_TYPE'
AND common_lookup_type = 'HOME')
,'USA','408','333-3333'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO contact
( contact_id
, member_id
, contact_type
, first_name
, middle_name
, last_name
, created_by
, creation_date
, last_updated_by
, last_update_date )
VALUES
( contact_s1.nextval
, member_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'CONTACT'
AND common_lookup_column = 'CONTACT_TYPE'
AND common_lookup_type = 'CUSTOMER')
,'Ian','M','Sweeney'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO address VALUES
( address_s1.nextval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'ADDRESS'
AND common_lookup_column = 'ADDRESS_TYPE'
AND common_lookup_type = 'HOME')
,'San Jose','CA','95192'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO street_address VALUES
( street_address_s1.nextval
, address_s1.currval
, 1
,'14 El Camino Real'
, 2, SYSDATE, 2, SYSDATE);
INSERT INTO telephone VALUES
( telephone_s1.nextval
, address_s1.currval
, contact_s1.currval
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'TELEPHONE'
AND common_lookup_column = 'TELEPHONE_TYPE'
AND common_lookup_type = 'HOME')
,'USA','408','333-3333'
, 2, SYSDATE, 2, SYSDATE);
/*
-- ------------------------------------------------------------------
-- Insert values in ITEM table.
-- ------------------------------------------------------------------ */
SELECT 'INSERT ITEM' AS "Section Header" FROM dual;
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0001US8F8'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Around the World in 80 Days'
,'Two-Disc Special Edition'
, empty_clob()
, NULL
,'NR'
,'MPAA'
,'18-MAY-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0002S64TQ'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Around the World in 80 Days'
,''
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'02-NOV-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000MNP2KI'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Casino Royale'
,''
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'13-MAR-2007'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000MNP2K8'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Casino Royale'
,''
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'13-MAR-2007'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00005JLBE'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Die Another Day'
,''
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'03-JUN-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000LY9CMC'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Die Another Day'
,'2-Disc Ultimate Version'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'03-JUN-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00008S2SF'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Die Another Day'
,''
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'03-JUN-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00000K0E5'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Golden Eye'
,'Special Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'22-OCT-2002'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000M53GM2'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Golden Eye'
,''
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'06-FEB-2007'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: 6304916558'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Tomorrow Never Dies'
,''
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'13-MAY-1998'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00000K0EA'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Tomorrow Never Dies'
,'Special Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'22-OCT-2002'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: 6305784922'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The World Is Not Enough'
,''
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'16-MAY-2000'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000NIBURQ'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The World Is Not Enough'
,''
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'22-MAY-2007'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00003CX95'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Brave Heart'
,''
, empty_clob()
, NULL
,'R'
,'MPAA'
,'29-AUG-2000'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: 6304712944'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Camelot'
,''
, empty_clob()
, NULL
,'G'
,'MPAA'
,'29-JUL-1998'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000B5XOZ2'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Christmas Carol'
,''
, empty_clob()
, NULL
,'NR'
,'MPAA'
,'08-NOV-2005'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00000K3CJ'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Christmas Carol'
,''
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'05-OCT-1999'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0000AQS5D'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Scrooge'
,''
, empty_clob()
, NULL
,'G'
,'MPAA'
,'23-SEP-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: 6305127719'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Clear and Present Danger'
,''
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'21-OCT-1998'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00008K76V'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Clear and Present Danger'
,'Special Collector''s Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'06-MAY-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00003CXI1'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Harry Potter and the Sorcer''s Stone'
,'Two-Disc Special Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'28-MAY-2002'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000062TU1'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Harry Potter and the Sorcer''s Stone'
,'Full Screen Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'28-MAY-2002'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00008DDXC'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Harry Potter and the Chamber of Secrets'
,'Two-Disc Special Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'11-APR-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00008DDXL'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Harry Potter and the Chamber of Secrets'
,'Full Screen Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'11-APR-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00005JMAH'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Harry Potter and the Prisoner of Azkaban'
,'Two-Disc Special Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'23-NOV-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0002TT0NW'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Harry Potter and the Prisoner of Azkaban'
,'2-Disc Full Screen Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'23-NOV-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0002VB24K'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Harry Potter and the Chamber of Secrets'
,''
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'23-NOV-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000E6EK2Y'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Harry Potter and the Goblet of Fire'
,'Widescreen Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'07-MAR-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000E6EK38'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Harry Potter and the Goblet of Fire'
,'Full Screen Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'07-MAR-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000E6EK3S'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Harry Potter and the Goblet of Fire'
,'Two-Disc Special Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'07-MAR-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000E6EZ3Z'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Harry Potter and the Order of the Phoenix'
,'Widescreen Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'11-DEC-2007'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: 6305182043'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Hunt for Red October'
,''
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'01-DEC-1998'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00008K76U'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Hunt for Red October'
,'Special Collector''s Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'06-MAY-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0002YLCG0'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'King Arthur - The Director''s Cut'
,'Wide Screen Edition'
, empty_clob()
, NULL
,'R'
,'MPAA'
,'21-DEC-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0002YLCFQ'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'King Arthur'
,'PG-13 Full Screen Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'21-DEC-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0002YLCG0'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'King Arthur - The Director''s Cut'
,'Wide Screen Edition'
, empty_clob()
, NULL
,'R'
,'MPAA'
,'21-DEC-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00003CWT6'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Lord of the Rings - Fellowship of the Ring'
,'Widescreen Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'06-AUG-2002'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000065U3Q'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'The Lord of the Rings - Fellowship of the Ring'
,'Fullscreen Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'06-AUG-2002'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000067DNF'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Lord of the Rings - Fellowship of the Ring'
,'Platinum Series Special Extended Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'12-NOV-2002'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00005JKZV'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Lord of the Rings - Two Towers'
,'Widescreen Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'26-AUG-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00009APK1'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'The Lord of the Rings - Two Towers'
,'Fullscreen Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'26-AUG-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00009TB5G'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Lord of the Rings - Two Towers'
,'Platinum Series Special Extended Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'18-NOV-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00005JKZY'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Lord of the Rings - The Return of the King'
,'Widescreen Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'25-MAY-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0001US8E4'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'The Lord of the Rings - The Return of the King'
,'Fullscreen Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'25-MAY-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000634DCW'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Lord of the Rings - The Return of the King'
,'Platinum Series Special Extended Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'14-DEC-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: 6305222878'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Patriot Games'
,''
, empty_clob()
, NULL
,'R'
,'MPAA'
,'15-DEC-1998'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00008K76W'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Patriot Games'
,'Special Collector''s Edition'
, empty_clob()
, NULL
,'R'
,'MPAA'
,'06-MAY-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00005JM5E'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Pirates of the Caribbean - The Curse of the Black Pearl'
,'Two-Disc Collector''s Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'02-DEC-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0002XL342'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Pirates of the Caribbean - The Curse of the Black Pearl'
,'Three-Disc Special Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'02-NOV-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0000C6DWS'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Pirates of the Caribbean - The Curse of the Black Pearl'
,''
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'02-DEC-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000I0RQVI'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Pirates of the Caribbean - Dead Man''s Chest'
,''
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'05-DEC-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00005JP0F'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Pirates of the Caribbean - Dead Man''s Chest'
,'Two-Disc Collector''s Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'05-DEC-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0R0I0RDEI'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Pirates of the Caribbean - At World''s End'
,''
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'05-DEC-2007'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0R0I0RRES'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Pirates of the Caribbean - At World''s End'
,'Two-Disc Collector''s Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'05-DEC-2007'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00009Q98M'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Indiana Jones and the Raiders of the Lost Ark'
,'Widescreen Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'20-FEB-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000F21K66'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Indiana Jones and the Raiders of the Lost Ark'
,'Fullscreen Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'20-FEB-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000F7OMZ2'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Indiana Jones and the Temple of Doom'
,'Widescreen Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'20-FEB-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000F7OMZ3'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Indiana Jones and the Temple of Doom'
,'Fullscreen Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'20-FEB-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000F7OPCC'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Indiana Jones and the Last Crusade'
,'Widescreen Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'20-FEB-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000F7OPCR'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Indiana Jones and the Last Crusade'
,'Fullscreen Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'20-FEB-2003'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00005JKCH'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Spider-Man'
,'Widescreen Special Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'01-NOV-2002'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00006F2TV'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Spider-Man'
,'Fullscreen Special Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'01-NOV-2002'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00005JMQW'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Spider-Man 2'
,'Widescreen Special Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'30-NOV-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0002XK186'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Spider-Man 2'
,'Fullscreen Special Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'30-NOV-2004'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: C00005JMQW'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Spider-Man 3'
,'Widescreen Special Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'30-NOV-2007'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: CB0002XK186'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Spider-Man 3'
,'Fullscreen Special Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'30-NOV-2007'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00003CX5P'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Star Wars - Episode I'
,'The Phantom Menace'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'22-MAR-2005'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00006HBUJ'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Star Wars - Episode II'
,'Attack of the Clones'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'22-MAR-2005'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00006HBUI'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Star Wars - Episode II'
,'Attack of the Clones'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'22-MAR-2005'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00005JLXH'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Star Wars - Episode III'
,'Revenge of the Sith'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'01-NOV-2005'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00006HBUI'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Star Wars - Episode III'
,'Revenge of the Sith'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'01-NOV-2005'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0006VIE4C'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Star Wars - Episode IV'
,'A New Hope'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'12-AUG-2005'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0236VIE4D'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Star Wars - Episode IV'
,'A New Hope'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'12-AUG-2005'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0006VIXGQ'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Star Wars - Episode V'
,'The Empire Strikes Back'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'12-AUG-2005'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0026VJLGD'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Star Wars - Episode V'
,'The Empire Strikes Back'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'12-AUG-2005'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00076SCPW'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Star Wars - Episode VI'
,'Return of the Jedi'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'12-AUG-2005'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00276LJKZ'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Star Wars - Episode VI'
,'Return of the Jedi'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'12-AUG-2005'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00005JL8F'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Sum of All Fears'
,'Special Collector''s Edition'
, empty_clob()
, NULL
,'PG-13'
,'MPAA'
,'29-OCT-2002'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00004XPPG'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Patriot'
,'Special Edition'
, empty_clob()
, NULL
,'R'
,'MPAA'
,'24-OCT-2000'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000ELL1S0'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'The Patriot'
,'Unrated Extended Cut'
, empty_clob()
, NULL
,'NR'
,'MPAA'
,'25-APR-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000068TPN'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'We Were Soldiers'
,''
, empty_clob()
, NULL
,'R'
,'MPAA'
,'20-AUG-2002'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000E8M0VA'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_WIDE_SCREEN')
,'Chronicles of Narnia - The Lion, the Witch and the Wardrobe'
,'Widescreen Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'04-APR-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00005JO1X'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'DVD_FULL_SCREEN')
,'Chronicles of Narnia - The Lion, the Witch and the Wardrobe'
,'Fullscreen Edition'
, empty_clob()
, NULL
,'PG'
,'MPAA'
,'04-APR-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0009EK534'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'GAMECUBE')
,'Chronicles of Narnia - The Lion, the Witch and the Wardrobe'
,''
, empty_clob()
, NULL
,'T'
,'ESRB'
,'15-JUN-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0009ELZXI'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'PLAYSTATION2')
,'Chronicles of Narnia - The Lion, the Witch and the Wardrobe'
,''
, empty_clob()
, NULL
,'T'
,'ESRB'
,'15-JUN-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B0009EP9DU'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'XBOX')
,'Chronicles of Narnia - The Lion, the Witch and the Wardrobe'
,''
, empty_clob()
, NULL
,'T'
,'ESRB'
,'15-JUN-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000930DPU'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'GAMECUBE')
,'Harry Potter: Goblet of Fire'
,''
, empty_clob()
, NULL
,'E10+'
,'ESRB'
,'15-JUN-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000930DQ4'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'PLAYSTATION2')
,'Harry Potter: Goblet of Fire'
,''
, empty_clob()
, NULL
,'E10+'
,'ESRB'
,'15-JUN-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000930DQE'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'XBOX')
,'Harry Potter: Goblet of Fire'
,''
, empty_clob()
, NULL
,'E10+'
,'ESRB'
,'15-JUN-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000930DPU'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'GAMECUBE')
,'Pirates of the Caribbean'
,''
, empty_clob()
, NULL
,'T'
,'ESRB'
,'15-JUN-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000FWAGNY'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'PLAYSTATION2')
,'Pirates of the Caribbean'
,'The Legend of Jack Sparrow'
, empty_clob()
, NULL
,'T'
,'ESRB'
,'27-JUN-2006'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B00008V6TF'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'XBOX')
,'Pirates of the Caribbean'
,''
, empty_clob()
, NULL
,'T'
,'ESRB'
,'22-MAY-2007'
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO item VALUES
( item_s1.nextval
,'ASIN: B000MK4G1M'
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_type = 'XBOX')
,'Pirates of the Caribbean'
,'At Worlds End'
, empty_clob()
, NULL
,'T'
,'ESRB'
,'22-MAY-2007'
, 3, SYSDATE, 3, SYSDATE);
-- ------------------------------------------------------------------
-- Inserts 5 rentals with 9 dependent rental items. This section
inserts
-- 5 rows in the RENTAL table, then 9 rows in the
RENTAL_ITEM table. The
-- inserts into the RENTAL_ITEM tables use scalar subqueries
to find the
-- proper foreign key values by querying the RENTAL table
primary keys.
-- ------------------------------------------------------------------
-- Insert 5 records in the RENTAL table.
-- ------------------------------------------------------------------
SELECT 'INSERT RENTAL' AS "Section Header" FROM dual;
INSERT INTO rental VALUES
( rental_s1.nextval
,(SELECT contact_id
FROM contact
WHERE last_name = 'Vizquel'
AND first_name = 'Oscar')
, SYSDATE, SYSDATE + 5
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO rental VALUES
( rental_s1.nextval
,(SELECT contact_id
FROM contact
WHERE last_name = 'Vizquel'
AND first_name = 'Doreen')
, SYSDATE, SYSDATE + 5
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO rental VALUES
( rental_s1.nextval
,(SELECT contact_id
FROM contact
WHERE last_name = 'Sweeney'
AND first_name = 'Meaghan')
, SYSDATE, SYSDATE + 5
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO rental VALUES
( rental_s1.nextval
,(SELECT contact_id
FROM contact
WHERE last_name = 'Sweeney'
AND first_name = 'Ian')
, SYSDATE, SYSDATE + 5
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO rental VALUES
( rental_s1.nextval
,(SELECT contact_id
FROM contact
WHERE last_name = 'Winn'
AND first_name = 'Brian')
, SYSDATE, SYSDATE + 5
, 3, SYSDATE, 3, SYSDATE);
/*
-- ------------------------------------------------------------------
-- Insert 9 records in the RENTAL_ITEM table.
-- ------------------------------------------------------------------ */
SELECT 'INSERT RENTAL_ITEM' AS "Section Header"
FROM dual;
INSERT INTO rental_item
( rental_item_id
, rental_id
, item_id
, rental_item_price
, rental_item_type
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( rental_item_s1.nextval
,(SELECT r.rental_id
FROM rental r
, contact c
WHERE r.customer_id = c.contact_id
AND c.last_name = 'Vizquel'
AND c.first_name = 'Oscar')
,(SELECT i.item_id
FROM item i
, common_lookup cl
WHERE i.item_title = 'Star Wars - Episode I'
AND i.item_subtitle = 'The Phantom Menace'
AND i.item_type = cl.common_lookup_id
AND cl.common_lookup_type = 'DVD_WIDE_SCREEN')
, 5
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'RENTAL_ITEM'
AND common_lookup_column = 'RENTAL_ITEM_TYPE'
AND common_lookup_type = '5-DAY RENTAL')
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO rental_item
( rental_item_id
, rental_id
, item_id
, rental_item_price
, rental_item_type
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( rental_item_s1.nextval
,(SELECT r.rental_id
FROM rental r inner join contact c
ON r.customer_id = c.contact_id
WHERE c.last_name = 'Vizquel'
AND c.first_name = 'Oscar')
,(SELECT d.item_id
FROM item d join common_lookup cl
ON d.item_title = 'Star Wars - Episode II'
WHERE d.item_subtitle = 'Attack of the Clones'
AND d.item_type = cl.common_lookup_id
AND cl.common_lookup_type = 'DVD_WIDE_SCREEN')
, 5
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'RENTAL_ITEM'
AND common_lookup_column = 'RENTAL_ITEM_TYPE'
AND common_lookup_type = '5-DAY RENTAL')
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO rental_item
( rental_item_id
, rental_id
, item_id
, rental_item_price
, rental_item_type
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( rental_item_s1.nextval
,(SELECT r.rental_id
FROM rental r
, contact c
WHERE r.customer_id = c.contact_id
AND c.last_name = 'Vizquel'
AND c.first_name = 'Oscar')
,(SELECT d.item_id
FROM item d
, common_lookup cl
WHERE d.item_title = 'Star Wars - Episode III'
AND d.item_subtitle = 'Revenge of the Sith'
AND d.item_type = cl.common_lookup_id
AND cl.common_lookup_type = 'DVD_WIDE_SCREEN')
, 5
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'RENTAL_ITEM'
AND common_lookup_column = 'RENTAL_ITEM_TYPE'
AND common_lookup_type = '5-DAY RENTAL')
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO rental_item
( rental_item_id
, rental_id
, item_id
, rental_item_price
, rental_item_type
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( rental_item_s1.nextval
,(SELECT r.rental_id
FROM rental r
, contact c
WHERE r.customer_id = c.contact_id
AND c.last_name = 'Vizquel'
AND c.first_name = 'Doreen')
,(SELECT d.item_id
FROM item d
, common_lookup cl
WHERE d.item_title = 'Tomorrow Never Dies'
AND d.item_subtitle IS NULL
AND d.item_type = cl.common_lookup_id
AND cl.common_lookup_type = 'DVD_WIDE_SCREEN')
, 5
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'RENTAL_ITEM'
AND common_lookup_column = 'RENTAL_ITEM_TYPE'
AND common_lookup_type = '5-DAY RENTAL')
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO rental_item
( rental_item_id
, rental_id
, item_id
, rental_item_price
, rental_item_type
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( rental_item_s1.nextval
,(SELECT r.rental_id
FROM rental r
, contact c
WHERE r.customer_id = c.contact_id
AND c.last_name = 'Vizquel'
AND c.first_name = 'Doreen')
,(SELECT d.item_id
FROM item d
, common_lookup cl
WHERE d.item_title = 'Around the World in 80 Days'
AND d.item_subtitle IS NULL
AND d.item_type = cl.common_lookup_id
AND cl.common_lookup_type = 'DVD_WIDE_SCREEN')
, 5
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'RENTAL_ITEM'
AND common_lookup_column = 'RENTAL_ITEM_TYPE'
AND common_lookup_type = '5-DAY RENTAL')
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO rental_item
( rental_item_id
, rental_id
, item_id
, rental_item_price
, rental_item_type
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( rental_item_s1.nextval
,(SELECT r.rental_id
FROM rental r
, contact c
WHERE r.customer_id = c.contact_id
AND c.last_name = 'Sweeney'
AND c.first_name = 'Meaghan')
,(SELECT d.item_id
FROM item d
, common_lookup cl
WHERE d.item_title = 'The Patriot'
AND d.item_subtitle = 'Special Edition'
AND d.item_type = cl.common_lookup_id
AND cl.common_lookup_type = 'DVD_WIDE_SCREEN')
, 5
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'RENTAL_ITEM'
AND common_lookup_column = 'RENTAL_ITEM_TYPE'
AND common_lookup_type = '5-DAY RENTAL')
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO rental_item
( rental_item_id
, rental_id
, item_id
, rental_item_price
, rental_item_type
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( rental_item_s1.nextval
,(SELECT r.rental_id
FROM rental r
, contact c
WHERE r.customer_id = c.contact_id
AND c.last_name = 'Sweeney'
AND c.first_name = 'Ian')
,(SELECT d.item_id
FROM item d
, common_lookup cl
WHERE d.item_title = 'Spider-Man'
AND d.item_subtitle = 'Fullscreen Special Edition'
AND d.item_type = cl.common_lookup_id
AND cl.common_lookup_type = 'DVD_FULL_SCREEN')
, 5
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'RENTAL_ITEM'
AND common_lookup_column = 'RENTAL_ITEM_TYPE'
AND common_lookup_type = '5-DAY RENTAL')
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO rental_item
( rental_item_id
, rental_id
, item_id
, rental_item_price
, rental_item_type
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( rental_item_s1.nextval
,(SELECT r.rental_id
FROM rental r
, contact c
WHERE r.customer_id = c.contact_id
AND c.last_name = 'Winn'
AND c.first_name = 'Brian')
,(SELECT d.item_id
FROM item d
, common_lookup cl
WHERE d.item_title = 'We Were Soldiers'
AND d.item_subtitle IS NULL
AND d.item_type = cl.common_lookup_id
AND cl.common_lookup_type = 'DVD_WIDE_SCREEN')
, 5
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'RENTAL_ITEM'
AND common_lookup_column = 'RENTAL_ITEM_TYPE'
AND common_lookup_type = '5-DAY RENTAL')
, 3, SYSDATE, 3, SYSDATE);
INSERT INTO rental_item
( rental_item_id
, rental_id
, item_id
, rental_item_price
, rental_item_type
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( rental_item_s1.nextval
,(SELECT r.rental_id
FROM rental r
, contact c
WHERE r.customer_id = c.contact_id
AND c.last_name = 'Winn'
AND c.first_name = 'Brian')
,(SELECT d.item_id
FROM item d
, common_lookup cl
WHERE d.item_title = 'The Hunt for Red October'
AND d.item_subtitle = 'Special Collector''s Edition'
AND d.item_type = cl.common_lookup_id
AND cl.common_lookup_type = 'DVD_WIDE_SCREEN')
, 5
,(SELECT common_lookup_id
FROM common_lookup
WHERE common_lookup_table = 'RENTAL_ITEM'
AND common_lookup_column = 'RENTAL_ITEM_TYPE'
AND common_lookup_type = '5-DAY RENTAL')
, 3, SYSDATE, 3, SYSDATE);
-- Write all prior to program units.
COMMIT;
-- ----------------------------------------------
-- Create update_price_function.
-- ----------------------------------------------
SELECT 'CREATE PRICE UPDATE FUNCTION' AS "Section
Header" FROM dual;
@@update_price_function.sql
SET SERVEROUTPUT ON SIZE UNLIMITED
DECLARE
lv_count INTEGER;
BEGIN
IF update_price = 0 THEN
SELECT COUNT(*) INTO lv_count FROM price;
dbms_output.put_line('Inserted Prices ['||lv_count||']
records.');
ELSE
dbms_output.put_line('No Prices Inserted.');
END IF;
END;
/
BEGIN
FOR i IN (SELECT product
FROM product_component_version
WHERE REGEXP_LIKE(product,'.+11g.+')) LOOP
dbms_output.put_line('Valid ['||i.product||'].');
END LOOP;
END;
/
-- This creates a transactionally safe individual member insert
-- into the MEMBER, CONTACT, ADDRESS,
STREET_ADDRESS, and
-- TELEPHONE tables for Oracle 11g; it won't run in Oracle
10g
-- and you should use the contact_insert_10g.sql script in the
-- create_store.sql when working on Oracle 10g XE.
@@contact_insert.sql
@@contact_insert_10g.sql
-- Insert complete contact information using stored procedure.
-- If you're running on Oracle 10g XE, switch contact_insert to
contact_insert_10g as
-- a procedure call in the following statements.
EXECUTE contact_insert('INDIVIDUAL','R11-514-34','1111-
1111-1111-
1111','VISA_CARD','Clinton','Goeffrey','Ward','CUSTOMER','
HOME','Provo','Utah','84606','118 South 9th
East','HOME','011','801','423-1234');
EXECUTE contact_insert('INDIVIDUAL','R11-514-35','1111-
1111-1111-
1111','VISA_CARD','Brandt','Henry','Ward','CUSTOMER','HO
ME','Provo','Utah','84606','118 South 9th
East','HOME','011','801','423-1234');
EXECUTE contact_insert('INDIVIDUAL','R11-514-36','1111-
2222-1111-
1111','VISA_CARD','Wendy','Jane','Moss','CUSTOMER','HOM
E','Provo','Utah','84606','1218 South 10th
East','HOME','011','801','423-1234');
EXECUTE contact_insert('INDIVIDUAL','R11-514-37','1111-
1111-2222-
1111','VISA_CARD','Jonah','Simon','Gretelz','CUSTOMER','HO
ME','Provo','Utah','84606','2118 South 7th
East','HOME','011','801','423-1234');
EXECUTE contact_insert('INDIVIDUAL','R11-514-38','1111-
1111-1111-
2222','MASTER_CARD','Jane','Elizabeth','Royal','CUSTOMER',
'HOME','Provo','Utah','84606','2228 South 14th
East','HOME','011','801','423-1234');
EXECUTE contact_insert_10g('INDIVIDUAL','R11-514-
39','1111-1111-3333-
1111','VISA_CARD','Brian','Nathan','Smith','CUSTOMER','HO
ME','Spanish Fork','Utah','84606','333 North 2nd
East','HOME','011','801','423-1234');
-- Place Chapter 6 Procedure in database.
@@transaction_procedure.sql
-- Update the address table.
UPDATE address
SET state_province = 'California'
WHERE state_province = 'CA';
-- Conditionally drop table.
BEGIN
FOR i IN (SELECT table_name
FROM user_tables
WHERE table_name = 'AIRPORT') LOOP
EXECUTE IMMEDIATE 'DROP TABLE '||i.table_name||'
CASCADE CONSTRAINTS';
END LOOP;
FOR i IN (SELECT sequence_name
FROM user_sequences
WHERE sequence_name = 'AIRPORT_S1') LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE
'||i.sequence_name;
END LOOP;
END;
/
-- Create table.
CREATE TABLE airport
( airport_id NUMBER CONSTRAINT pk_airport
PRIMARY KEY
, airport_code VARCHAR2(3) CONSTRAINT nn_airport1
NOT NULL
, airport_city VARCHAR2(30) CONSTRAINT nn_airport2
NOT NULL
, city VARCHAR2(30) CONSTRAINT nn_airport3
NOT NULL
, state_province VARCHAR2(30) CONSTRAINT nn_airport4
NOT NULL
, created_by NUMBER
, creation_date DATE
, last_updated_by NUMBER
, last_update_date DATE
, CONSTRAINT fk_airport1 FOREIGN KEY (created_by)
REFERENCES system_user (system_user_id)
, CONSTRAINT fk_airport2 FOREIGN KEY (last_updated_by)
REFERENCES system_user (system_user_id));
-- Create sequence.
CREATE SEQUENCE airport_s1;
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx

More Related Content

Similar to PROG3040 Assignment 1 – Fall 2013 Glenn Paulley – 2A605, x25.docx

Name _______________________________ Class time __________.docx
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docxrosemarybdodson23141
 
Cover PageComplete and copy the following to Word for your cover p.docx
Cover PageComplete and copy the following to Word for your cover p.docxCover PageComplete and copy the following to Word for your cover p.docx
Cover PageComplete and copy the following to Word for your cover p.docxfaithxdunce63732
 
Question 1Using Powerpoint, Word, Visio or any other graphical e.docx
Question 1Using Powerpoint, Word, Visio or any other graphical e.docxQuestion 1Using Powerpoint, Word, Visio or any other graphical e.docx
Question 1Using Powerpoint, Word, Visio or any other graphical e.docxIRESH3
 
DashboardUMUC DATA 620Assignment 3.1Your NameProfessorDateProbl.docx
DashboardUMUC DATA 620Assignment 3.1Your NameProfessorDateProbl.docxDashboardUMUC DATA 620Assignment 3.1Your NameProfessorDateProbl.docx
DashboardUMUC DATA 620Assignment 3.1Your NameProfessorDateProbl.docxsimonithomas47935
 
C++ Programming Class Creation Program Assignment Instructions
C++ Programming Class Creation Program Assignment InstructionsC++ Programming Class Creation Program Assignment Instructions
C++ Programming Class Creation Program Assignment InstructionsTawnaDelatorrejs
 
Important notes· NOTE it is usually fine and often encouraged i.docx
Important notes· NOTE it is usually fine and often encouraged i.docxImportant notes· NOTE it is usually fine and often encouraged i.docx
Important notes· NOTE it is usually fine and often encouraged i.docxwilcockiris
 
COMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docx
COMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docxCOMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docx
COMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docxdonnajames55
 
Bt0082, visual basic
Bt0082, visual basicBt0082, visual basic
Bt0082, visual basicsmumbahelp
 
Relational Model
Relational ModelRelational Model
Relational ModelSiti Ismail
 
Vizwik Coding Manual
Vizwik Coding ManualVizwik Coding Manual
Vizwik Coding ManualVizwik
 
Bc0053 – vb.net & xml
Bc0053 – vb.net & xmlBc0053 – vb.net & xml
Bc0053 – vb.net & xmlsmumbahelp
 
5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMSkoolkampus
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answersdebarghyamukherjee60
 
CPSC 50900 Database Systems ProjectAll your efforts this semeste
CPSC 50900 Database Systems ProjectAll your efforts this semesteCPSC 50900 Database Systems ProjectAll your efforts this semeste
CPSC 50900 Database Systems ProjectAll your efforts this semesteCruzIbarra161
 
DataWeave 2.0 - MuleSoft CONNECT 2019
DataWeave 2.0 - MuleSoft CONNECT 2019DataWeave 2.0 - MuleSoft CONNECT 2019
DataWeave 2.0 - MuleSoft CONNECT 2019Sabrina Marechal
 
CSC8503 Principles of Programming Languages Semester 1, 2015.docx
CSC8503 Principles of Programming Languages Semester 1, 2015.docxCSC8503 Principles of Programming Languages Semester 1, 2015.docx
CSC8503 Principles of Programming Languages Semester 1, 2015.docxfaithxdunce63732
 
Bt0082 visual basic2
Bt0082 visual basic2Bt0082 visual basic2
Bt0082 visual basic2Techglyphs
 

Similar to PROG3040 Assignment 1 – Fall 2013 Glenn Paulley – 2A605, x25.docx (20)

Name _______________________________ Class time __________.docx
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docx
 
Cover PageComplete and copy the following to Word for your cover p.docx
Cover PageComplete and copy the following to Word for your cover p.docxCover PageComplete and copy the following to Word for your cover p.docx
Cover PageComplete and copy the following to Word for your cover p.docx
 
Question 1Using Powerpoint, Word, Visio or any other graphical e.docx
Question 1Using Powerpoint, Word, Visio or any other graphical e.docxQuestion 1Using Powerpoint, Word, Visio or any other graphical e.docx
Question 1Using Powerpoint, Word, Visio or any other graphical e.docx
 
DashboardUMUC DATA 620Assignment 3.1Your NameProfessorDateProbl.docx
DashboardUMUC DATA 620Assignment 3.1Your NameProfessorDateProbl.docxDashboardUMUC DATA 620Assignment 3.1Your NameProfessorDateProbl.docx
DashboardUMUC DATA 620Assignment 3.1Your NameProfessorDateProbl.docx
 
C++ Programming Class Creation Program Assignment Instructions
C++ Programming Class Creation Program Assignment InstructionsC++ Programming Class Creation Program Assignment Instructions
C++ Programming Class Creation Program Assignment Instructions
 
Important notes· NOTE it is usually fine and often encouraged i.docx
Important notes· NOTE it is usually fine and often encouraged i.docxImportant notes· NOTE it is usually fine and often encouraged i.docx
Important notes· NOTE it is usually fine and often encouraged i.docx
 
COMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docx
COMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docxCOMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docx
COMP 2213X2 Assignment #2 Parts A and BDue February 3 in cla.docx
 
Bt0082, visual basic
Bt0082, visual basicBt0082, visual basic
Bt0082, visual basic
 
Relational Model
Relational ModelRelational Model
Relational Model
 
Vizwik Coding Manual
Vizwik Coding ManualVizwik Coding Manual
Vizwik Coding Manual
 
Bc0053 – vb.net & xml
Bc0053 – vb.net & xmlBc0053 – vb.net & xml
Bc0053 – vb.net & xml
 
5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS
 
Bt0065
Bt0065Bt0065
Bt0065
 
B T0065
B T0065B T0065
B T0065
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answers
 
CPSC 50900 Database Systems ProjectAll your efforts this semeste
CPSC 50900 Database Systems ProjectAll your efforts this semesteCPSC 50900 Database Systems ProjectAll your efforts this semeste
CPSC 50900 Database Systems ProjectAll your efforts this semeste
 
DataWeave 2.0 - MuleSoft CONNECT 2019
DataWeave 2.0 - MuleSoft CONNECT 2019DataWeave 2.0 - MuleSoft CONNECT 2019
DataWeave 2.0 - MuleSoft CONNECT 2019
 
CSC8503 Principles of Programming Languages Semester 1, 2015.docx
CSC8503 Principles of Programming Languages Semester 1, 2015.docxCSC8503 Principles of Programming Languages Semester 1, 2015.docx
CSC8503 Principles of Programming Languages Semester 1, 2015.docx
 
Bt0082 visual basic2
Bt0082 visual basic2Bt0082 visual basic2
Bt0082 visual basic2
 
Oops lecture 1
Oops lecture 1Oops lecture 1
Oops lecture 1
 

More from wkyra78

Melissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docx
Melissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docxMelissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docx
Melissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docxwkyra78
 
Melissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docx
Melissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docxMelissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docx
Melissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docxwkyra78
 
Meiner, S. E., & Yeager, J. J. (2019). Chapter 17Chap.docx
Meiner, S. E., & Yeager, J. J. (2019).    Chapter 17Chap.docxMeiner, S. E., & Yeager, J. J. (2019).    Chapter 17Chap.docx
Meiner, S. E., & Yeager, J. J. (2019). Chapter 17Chap.docxwkyra78
 
member is a security software architect in a cloud service provider .docx
member is a security software architect in a cloud service provider .docxmember is a security software architect in a cloud service provider .docx
member is a security software architect in a cloud service provider .docxwkyra78
 
Melissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docx
Melissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docxMelissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docx
Melissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docxwkyra78
 
Melissa is a 15-year-old high school student. Over the last week.docx
Melissa is a 15-year-old high school student. Over the last week.docxMelissa is a 15-year-old high school student. Over the last week.docx
Melissa is a 15-year-old high school student. Over the last week.docxwkyra78
 
Measurement  of  the  angle  θ          .docx
Measurement  of  the  angle  θ          .docxMeasurement  of  the  angle  θ          .docx
Measurement  of  the  angle  θ          .docxwkyra78
 
Measurement of the angle θ For better understanding .docx
Measurement of the angle θ     For better understanding .docxMeasurement of the angle θ     For better understanding .docx
Measurement of the angle θ For better understanding .docxwkyra78
 
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docxMeaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docxwkyra78
 
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docxMBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docxwkyra78
 
Medication Errors Led to Disastrous Outcomes1. Search th.docx
Medication Errors Led to Disastrous Outcomes1. Search th.docxMedication Errors Led to Disastrous Outcomes1. Search th.docx
Medication Errors Led to Disastrous Outcomes1. Search th.docxwkyra78
 
Meet, call, Skype or Zoom with a retired athlete and interview himh.docx
Meet, call, Skype or Zoom with a retired athlete and interview himh.docxMeet, call, Skype or Zoom with a retired athlete and interview himh.docx
Meet, call, Skype or Zoom with a retired athlete and interview himh.docxwkyra78
 
Medication Administration Make a list of the most common med.docx
Medication Administration Make a list of the most common med.docxMedication Administration Make a list of the most common med.docx
Medication Administration Make a list of the most common med.docxwkyra78
 
media portfolio”about chapter 1 to 15 from the book  Ci.docx
media portfolio”about chapter 1 to 15 from the book  Ci.docxmedia portfolio”about chapter 1 to 15 from the book  Ci.docx
media portfolio”about chapter 1 to 15 from the book  Ci.docxwkyra78
 
MediationNameAMUDate.docx
MediationNameAMUDate.docxMediationNameAMUDate.docx
MediationNameAMUDate.docxwkyra78
 
Media coverage influences the publics perception of the crimina.docx
Media coverage influences the publics perception of the crimina.docxMedia coverage influences the publics perception of the crimina.docx
Media coverage influences the publics perception of the crimina.docxwkyra78
 
Media Content AnalysisPurpose Evaluate the quality and value of.docx
Media Content AnalysisPurpose Evaluate the quality and value of.docxMedia Content AnalysisPurpose Evaluate the quality and value of.docx
Media Content AnalysisPurpose Evaluate the quality and value of.docxwkyra78
 
Mayan gods and goddesses are very much a part of this text.  Their i.docx
Mayan gods and goddesses are very much a part of this text.  Their i.docxMayan gods and goddesses are very much a part of this text.  Their i.docx
Mayan gods and goddesses are very much a part of this text.  Their i.docxwkyra78
 
Media and SocietyIn 1,100 words, complete the followingAn.docx
Media and SocietyIn 1,100 words, complete the followingAn.docxMedia and SocietyIn 1,100 words, complete the followingAn.docx
Media and SocietyIn 1,100 words, complete the followingAn.docxwkyra78
 
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docxMBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docxwkyra78
 

More from wkyra78 (20)

Melissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docx
Melissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docxMelissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docx
Melissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docx
 
Melissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docx
Melissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docxMelissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docx
Melissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docx
 
Meiner, S. E., & Yeager, J. J. (2019). Chapter 17Chap.docx
Meiner, S. E., & Yeager, J. J. (2019).    Chapter 17Chap.docxMeiner, S. E., & Yeager, J. J. (2019).    Chapter 17Chap.docx
Meiner, S. E., & Yeager, J. J. (2019). Chapter 17Chap.docx
 
member is a security software architect in a cloud service provider .docx
member is a security software architect in a cloud service provider .docxmember is a security software architect in a cloud service provider .docx
member is a security software architect in a cloud service provider .docx
 
Melissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docx
Melissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docxMelissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docx
Melissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docx
 
Melissa is a 15-year-old high school student. Over the last week.docx
Melissa is a 15-year-old high school student. Over the last week.docxMelissa is a 15-year-old high school student. Over the last week.docx
Melissa is a 15-year-old high school student. Over the last week.docx
 
Measurement  of  the  angle  θ          .docx
Measurement  of  the  angle  θ          .docxMeasurement  of  the  angle  θ          .docx
Measurement  of  the  angle  θ          .docx
 
Measurement of the angle θ For better understanding .docx
Measurement of the angle θ     For better understanding .docxMeasurement of the angle θ     For better understanding .docx
Measurement of the angle θ For better understanding .docx
 
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docxMeaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
 
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docxMBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
 
Medication Errors Led to Disastrous Outcomes1. Search th.docx
Medication Errors Led to Disastrous Outcomes1. Search th.docxMedication Errors Led to Disastrous Outcomes1. Search th.docx
Medication Errors Led to Disastrous Outcomes1. Search th.docx
 
Meet, call, Skype or Zoom with a retired athlete and interview himh.docx
Meet, call, Skype or Zoom with a retired athlete and interview himh.docxMeet, call, Skype or Zoom with a retired athlete and interview himh.docx
Meet, call, Skype or Zoom with a retired athlete and interview himh.docx
 
Medication Administration Make a list of the most common med.docx
Medication Administration Make a list of the most common med.docxMedication Administration Make a list of the most common med.docx
Medication Administration Make a list of the most common med.docx
 
media portfolio”about chapter 1 to 15 from the book  Ci.docx
media portfolio”about chapter 1 to 15 from the book  Ci.docxmedia portfolio”about chapter 1 to 15 from the book  Ci.docx
media portfolio”about chapter 1 to 15 from the book  Ci.docx
 
MediationNameAMUDate.docx
MediationNameAMUDate.docxMediationNameAMUDate.docx
MediationNameAMUDate.docx
 
Media coverage influences the publics perception of the crimina.docx
Media coverage influences the publics perception of the crimina.docxMedia coverage influences the publics perception of the crimina.docx
Media coverage influences the publics perception of the crimina.docx
 
Media Content AnalysisPurpose Evaluate the quality and value of.docx
Media Content AnalysisPurpose Evaluate the quality and value of.docxMedia Content AnalysisPurpose Evaluate the quality and value of.docx
Media Content AnalysisPurpose Evaluate the quality and value of.docx
 
Mayan gods and goddesses are very much a part of this text.  Their i.docx
Mayan gods and goddesses are very much a part of this text.  Their i.docxMayan gods and goddesses are very much a part of this text.  Their i.docx
Mayan gods and goddesses are very much a part of this text.  Their i.docx
 
Media and SocietyIn 1,100 words, complete the followingAn.docx
Media and SocietyIn 1,100 words, complete the followingAn.docxMedia and SocietyIn 1,100 words, complete the followingAn.docx
Media and SocietyIn 1,100 words, complete the followingAn.docx
 
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docxMBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 

PROG3040 Assignment 1 – Fall 2013 Glenn Paulley – 2A605, x25.docx

  • 1. PROG3040 Assignment 1 – Fall 2013 Glenn Paulley – 2A605, x2525 Assignment Type: INDIVIDUAL Due Date: 2-October-2013 (Wednesday), 10 a.m. Submission: via D2L drop-box; please take all of the files documented below and combine them into a single .zip file using WinZip so that your D2L submission is a single .zip file. In addition, paper output (script and results for marking) is due in class on 3 October 2013 (or before). Instructions: · Ensure that you have run the latest version of the database creation script files located in K:GPAULLEYPROG3040DATABASESPLSQL_WORKBOO Kstoredbcreate_workbook_store.sql to create the required tables and data. · Familiarize yourself with the assignment standards. You should, at a minimum, capitalize SQL language keywords. Identifiers may be in lower case or mixed case – strive for consistency. Be neat. Task 1. Database design and functional dependencies. [10 marks] Closure: Certain functional dependencies imply others. Given a set F of functional dependencies that hold for a table R, the closureF+ of that set is the set of all FDs implied by the FDs in F. F+ can be computed by applying Armstrong’s axioms to F. Furthermore, given a subset Z of the attributes of a table R, and a set F of functional dependencies that hold for R, the closureZ+ of Z is defined as the set X of the attributes of R such that the functional dependency Z X is a member of F+. If the closures F+ and G+ of two sets of dependencies F and G are equal, then we say that F and G are equivalent.
  • 2. To repeat from class, here are Armstrong’s axioms for functional dependencies, and additional axioms that can be derived from Armstrong’s original three axioms. Remember that X, Y, and Z are sets of attributes: 1. Inclusion: if Y is a subset of X, then X Y. 2. Augmentation: if X Y then WX WY. 3. Transitivity: if X Y and Y Z then X Z. Other axioms: · Self-determination: for any X, X X. X X is known as a trivial functional dependency. · Union: if X Y and X Z then X YZ. · Decomposition: if X YZ then X Y and X Z. · Composition: if X Y and W Z, then XW YZ. · Pseudo-transitivity: if X Y and WY Z then XW Z. Example. Suppose we have a table R with non-null attributes A, B, C, D; we commonly write this as R( A, B, C, D). Further suppose we have the following set F of non-trivial functional dependencies: · A B · B C · BC D We can determine the closure A+ of A as follows: We are given A B. Trivially, attribute A functionally determines itself, so we have A A. Since we are given B C, by transitivity we have A C (because A B and B C, thus A C). Combining these through union, we have A ABC. Finally, with BC D, again by transitivity we have A D, because A BC and BC D, and therefore A D. Combining again, we have A ABCD, that is, A functionally determines all of the attributes of R. (Aside: hence A is called a superkey of R). Task 1, Question 1: Suppose we have the table S with non-null attributes A through G; that is, we have
  • 3. S( A, B, C, D, E, F, G). Suppose we are given that S satisfies the following set G of non-trivial functional dependencies: · A B · BC DE · AEF G (1a). Determine the closure { A,C }+ under this set G of functional dependencies; remember that closure includes self- determination. Remember from mathematics that a pair of braces ({}) denotes a set; hence {A,C} denotes a set made up of the union of attributes from the sets A and C. Is the closure {A,C }+ equal to (choose one only): i.) ABC ii.) ABCDE iii.) AC iv.) ABCDEFG v.) ACDFG (1b). Is the functional dependency ACF DG implied by G? (Answer yes or no). Submit your responses to 1(a) and 1(b) in a separate text file. Name your file Task1Q1XX.txt where XX are your first and last initials. You’ll include this file in your D2L submission. Task 1, Question 2: [30 marks] Create an SQL script that creates a set of tables in Boyce-Codd Normal Form to represent entities in an order/entry system. Note: as is often the case, there is no “right answer” for doing this; logical database design is always subject to tradeoffs because normalizing every functional dependency usually isn’t desirable. For example, we usually do not decompose the functional dependency address postal code because there is little value in doing so. An example from the schema used in the textbook are the superfluous tables for telephone numbers and street addresses. This order/entry system will retain information similar to that modelled by the Video Store schema documented in the textbook, but with some differences. To prevent confusion with
  • 4. the Video Store tables, prefix all of your table names for this new set of tables with “PG$_”. Use lowercase and underscores for table and column names and for constraint names. Your new schema is to include at least the following information: · For each customer: · Customer number (unique) · Personal information (names) · “Ship-to” addresses (multiple addresses per customer) · Balance · Credit Limit · Discount percentage · For each order: · Order information: customer number, ship-to address, date of order · Detail lines (several per order): item number, quantity ordered · For each item: · Item number (unique) · Manufacturing plants (a plant may manufacture many items; each item may be manufactured by different plants) · Quantity-on-hand at each plant · Stock danger level at each plant · Item description · For each plant: · Mailing Address · Contact information · Telephone number · Assume that the company intends to handle tens of thousands of items in total, and thousands of orders per month. · Also, for processing reasons a “quantity outstanding” value is associated with each detail line of each order; this value is initially set equal to the quantity of the item ordered and is progressively reduced to zero as (partial) shipments are made. If you need to create surrogate keys for entities in this schema, choose data types and formats that are appropriate for the purpose. Include comment lines in your schema creation script
  • 5. that documents your proposed surrogate key formats, and why you chose those formats and data types. In addition to creating the appropriate tables and their columns, define the appropriate referential integrity constraints (primary keys and foreign keys) that relate the tables together. Give each referential constraint an appropriate name. Your marks for this question will be based on the “reasonable- ness” of your design choices. You should provide commentary (in the form of comments in your SQL script) that explains your design choices, particularly if there might be debate about such a choice. Appropriate commentary will enhance your mark. Create a script file (Task1Q2XX.sql, where XX are your initials in upper case letters) that creates the tables. You will include both your completed script file and its output file (Task1Q2XX.out) to your .zip file submission to D2L. Task 2. SQL Queries [10 marks each] Create a script file (Task2XX.sql, where XX are your initials in upper case letters) to combine the SQL queries for each problem below, in order. You will submit both your completed script file and its combined output file (Task2XX.out) to D2L. 1) Write a single SQL query that computes, for each contact, the average and sum of the rental transactions for rentals that were made in June 2011 (they could have possibly been returned in July or later). Include the overall grand total and overall transaction average in the result. You may not use a UNION query expression for your answer. For each contact, output: a. Contact ID b. Contact last name c. Contact first name d. Sum of the contact’s transactions for June 2011, in the format $9999.99 e. Average of the contact’s transactions for June 2011, in the format $99.99 f. For the grand total, substitute the literal string ‘June 2011 totals’ for the contact’s last name.
  • 6. g. Output the list of contacts ordered by first name within last name. Hints: i. Use COALESCE() to substitute the ‘June 2011 totals’ string in the output ii. Use GROUP BY ROLLUP iii. Use a derived table in the FROM clause iv. You will find the EXTRACT() and TO_CHAR() functions useful 2) Using the Video Store schema, write a query to produce a list of items that have never been rented. (Note: there is currently only one, with the Item ID of 1000). Rewrite your query in at least three different ways – that are semantically equivalent – that will return the identical result. Your rewrites may not be trivial ones – for example, reordering tables in the FROM clause or reordering predicates in the WHERE clause, or reversing or negating comparison operations. 3) Using the Video Store schema, write a query to produce a report that lists the number of times each of the Star Wars movies were rented in October, 2011. Include the total rental amount for each of the films. Consider only those movies in Wide Screen format on DVD. Output the ID of each film, its title, the number of times it was rented in October 2011 (use the column heading “Rentals”) and the total rental amount for each film, using proper money formatting in dollars and cents – use the column header “Total Amt” for this column. Order your result by film title. 4) Using the HR schema, write a query that lists all of the departments located in Seattle, Washington, along with their managers and the start date for each manager. If a department does not have a manager, output the value “Unknown”. Output the manager’s start date using the format “YYYY-MM-DD”. If the start date for that manager is unknown, also use the literal
  • 7. “Unknown”. Use appropriate headings for each column in the result. Order the list by department name. Task 3. Supplementary task. [5 marks] You have come into possession of a vintage VHS tape (on two cassettes) of the film “Lawrence of Arabia”. Add the tape to the Item table in the Video Store database using an INSERT statement that contains the necessary SELECT subquery to determine the proper item type code for this VHS double-set. COMMIT the change. Once the film has been added to the database, re-run your queries from Task 2, Item 2. Ensure that your queries find both the new “Lawrence of Arabia” film, and the “Pirates of the Caribbean” film, both of which have yet to be rented. After your query executes, delete the “Lawrence of Arabia” film using a DELETE statement, and COMMIT the deletion as part of your SQL script. Create a script file (Task3ExtraXX.sql) that creates the new item, answers the queries, and deletes the item. Submit to D2L both your completed script file and output file (Task3ExtraXX.lst). create_workbook_store.sql -- create_store.sql -- Introcution, Oracle Database 11g PL/SQL Programming Workbook -- by Michael McLaughlin and John Harper -- -- This demonstrates building a DVD, Game Cartridge and VHS tape store.
  • 8. -- It also highlights constraints and compound check constraints and -- seeds the tables with data. SPOOL create_store.log SET ECHO OFF SET FEEDBACK ON SET NULL '<Null>' SET PAGESIZE 999 SET SERVEROUTPUT ON -- Conditionally drop objects. BEGIN FOR i IN (SELECT null FROM user_tables WHERE table_name = 'SYSTEM_USER') LOOP EXECUTE IMMEDIATE 'DROP TABLE system_user
  • 9. CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'SYSTEM_USER_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE system_user_s1'; END LOOP; END; / -- ------------------------------------------------------------------ -- Create SYSTEM_USER table and sequence and seed data. -- ------------------------------------------------------------------ CREATE TABLE system_user ( system_user_id NUMBER CONSTRAINT pk_system_user PRIMARY KEY , system_user_name VARCHAR2(20) CONSTRAINT
  • 10. nn_system_user_1 NOT NULL , system_user_group_id NUMBER CONSTRAINT nn_system_user_2 NOT NULL , system_user_type NUMBER CONSTRAINT nn_system_user_3 NOT NULL , last_name VARCHAR2(20) , first_name VARCHAR2(20) , middle_initial VARCHAR2(1) , created_by NUMBER CONSTRAINT nn_system_user_4 NOT NULL , creation_date DATE CONSTRAINT nn_system_user_5 NOT NULL , last_updated_by NUMBER CONSTRAINT nn_system_user_6 NOT NULL , last_update_date DATE CONSTRAINT nn_system_user_7 NOT NULL); CREATE SEQUENCE system_user_s1 START WITH 1000; INSERT INTO system_user VALUES ( 1,'SYSADMIN',1,1,1,NULL,NULL,1,SYSDATE,1,SYSDATE);
  • 11. ALTER TABLE system_user ADD CONSTRAINT fk_system_user_1 FOREIGN KEY(created_by) REFERENCES system_user(system_user_id); ALTER TABLE system_user ADD CONSTRAINT fk_system_user_2 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id); -- Conditionally drop objects. BEGIN FOR i IN (SELECT null FROM user_tables WHERE table_name = 'COMMON_LOOKUP') LOOP EXECUTE IMMEDIATE 'DROP TABLE common_lookup CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences
  • 12. WHERE sequence_name = 'COMMON_LOOKUP_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE common_lookup_s1'; END LOOP; END; / -- ------------------------------------------------------------------ -- Create COMMON_LOOKUP table and sequence and seed data. -- ------------------------------------------------------------------ CREATE TABLE common_lookup ( common_lookup_id NUMBER CONSTRAINT pk_common_lookup PRIMARY KEY , common_lookup_table VARCHAR2(30) CONSTRAINT nn_common_lookup_1 NOT NULL , common_lookup_column VARCHAR2(30) CONSTRAINT nn_common_lookup_2 NOT NULL , common_lookup_type VARCHAR2(30) CONSTRAINT nn_common_lookup_3 NOT NULL
  • 13. , common_lookup_code VARCHAR2(8) , common_lookup_meaning VARCHAR2(255) CONSTRAINT nn_common_lookup_4 NOT NULL , created_by NUMBER CONSTRAINT nn_common_lookup_5 NOT NULL , creation_date DATE CONSTRAINT nn_common_lookup_6 NOT NULL , last_updated_by NUMBER CONSTRAINT nn_common_lookup_7 NOT NULL , last_update_date DATE CONSTRAINT nn_common_lookup_8 NOT NULL , CONSTRAINT fk_common_lookup_1 FOREIGN KEY(created_by) REFERENCES system_user(system_user_id) , CONSTRAINT fk_common_lookup_2 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id)); CREATE INDEX common_lookup_n1 ON common_lookup(common_lookup_table);
  • 14. CREATE UNIQUE INDEX common_lookup_u2 ON common_lookup(common_lookup_table,common_lookup_colum n,common_lookup_type); CREATE SEQUENCE common_lookup_s1 START WITH 1000; -- ------------------------------------------------------------------ -- Insert Common Lookups. -- ------------------------------------------------------------------ SELECT 'INSERT COMMON_LOOKUP' AS "Section Header" FROM dual; INSERT INTO common_lookup VALUES ( 1,'SYSTEM_USER','SYSTEM_USER_TYPE','SYSTEM_ADMI N',NULL,'System Administrator' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES (
  • 15. common_lookup_s1.nextval,'SYSTEM_USER','SYSTEM_USER _TYPE','DBA',NULL,'Database Administrator' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'CONTACT','CONTACT_TYPE','E MPLOYEE',NULL,'Employee' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'CONTACT','CONTACT_TYPE','C USTOMER',NULL,'Customer' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'MEMBER','MEMBER_TYPE','IND IVIDUAL',NULL,'Individual Membership' , 1, SYSDATE, 1, SYSDATE);
  • 16. INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'MEMBER','MEMBER_TYPE','GR OUP',NULL,'Group Membership' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'MEMBER','CREDIT_CARD_TYPE ','DISCOVER_CARD',NULL,'Discover Card' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'MEMBER','CREDIT_CARD_TYPE ','MASTER_CARD',NULL,'Master Card' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'MEMBER','CREDIT_CARD_TYPE ','VISA_CARD',NULL,'VISA Card'
  • 17. , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ADDRESS','ADDRESS_TYPE','H OME',NULL,'Home' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ADDRESS','ADDRESS_TYPE','W ORK',NULL,'Work' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'TELEPHONE','TELEPHONE_TYP E','HOME',NULL,'Home' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES
  • 18. ( common_lookup_s1.nextval,'TELEPHONE','TELEPHONE_TYP E','WORK',NULL,'Work' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_TYPE','DVD_FULL _SCREEN',NULL,'DVD: Full Screen' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_TYPE','DVD_WIDE _SCREEN',NULL,'DVD: Wide Screen' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_TYPE','GAMECUBE ',NULL,'Nintendo GameCube' , 1, SYSDATE, 1, SYSDATE);
  • 19. INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_TYPE','PLAYSTATI ON2',NULL,'PlayStation2' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_TYPE','XBOX',NUL L,'XBOX' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_TYPE','VHS_SINGL E_TAPE',NULL,'VHS: Single Tape' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES (
  • 20. common_lookup_s1.nextval,'ITEM','ITEM_TYPE','VHS_DOUB LE_TAPE',NULL,'VHS: Double Tape' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING_AGENCY' ,'MPAA','MPAA','Motion Picture Association of America' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING_AGENCY' ,'ESRB','ESRB','Entertainment Software Rating Board' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','MPAA G','G','G - General Audiences: All ages admitted.' , 1, SYSDATE, 1, SYSDATE);
  • 21. INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','MPAA PG','PG','PG - Parental guidance suggested: Some material may not be suitable for children.' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','MPAA PG-13','PG-13','PG-13 - Parents strongly cautioned: Some material may be inappropriate for children under 13.' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','MPAA R','R','R - Restricted: Under 17 requires accompanying parent or adult guardian.' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','MPAA NC-17','NC-17','NC-17 - No one 17 and under admitted.' , 1, SYSDATE, 1, SYSDATE);
  • 22. INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','MPAA NR','NR','NR - Not Rated.' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB EC','ED','EC - Early Childhood: Contains content that may be suitable for ages 3 and older. Contains no material that parents would find inappropriate.' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB E','E','E - Everyone: Contains content that may be suitable for ages 6 and older. Titles in this category may contain minimal cartoon, fantasy or mild violence and/or infrequent use of mild language.' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES
  • 23. ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB E10+','E10+','E10+ - Everyone 10+: Contains content that may be suitable for ages 10 and older. Titles in this category may contain more cartoon, fantasy or mild violence, mild language, minimal and/or infrequent blood and/or minimal suggestive themes.' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB T','T','T - Teen: Contains content that may be suitable for ages 13 and older. Titles in this category may contain violence, suggestive themes, crude humor, minimal blood, simulated gambling, and/or infrequent use of strong language.' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB M','M','M - Mature: Contains content that may be suitable for ages 17 and older. Titles in this category may contain intense violence, blood and gore, sexual content and/or strong language.' , 1, SYSDATE, 1, SYSDATE);
  • 24. INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB AO','AO','AO - Adult Only: Contains content that is suitable only for adults. Titles in this category may include prolonged scenes of intense violence and/or graphic sexual content and nudity.' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'ITEM','ITEM_RATING','ESRB RP','RP','RP - Rating Pending: Product has been submitted to the ESRB and is awaiting final rating (prior to product release).' , 1, SYSDATE, 1, SYSDATE); INSERT INTO COMMON_LOOKUP VALUES ( common_lookup_s1.nextval, 'TRANSACTION', 'TRANSACTION_TYPE', 'DEBIT', 'DB', 'Debit', 1, SYSDATE, 1, SYSDATE); INSERT INTO COMMON_LOOKUP VALUES ( common_lookup_s1.nextval, 'TRANSACTION', 'TRANSACTION_TYPE', 'CREDIT', 'CR', 'Credit', 1, SYSDATE, 1, SYSDATE);
  • 25. INSERT INTO COMMON_LOOKUP VALUES ( common_lookup_s1.nextval, 'TRANSACTION', 'PAYMENT_METHOD_TYPE', 'DISCOVER_CARD', '', 'Discover Card', 1, SYSDATE, 1, SYSDATE); INSERT INTO COMMON_LOOKUP VALUES ( common_lookup_s1.nextval, 'TRANSACTION', 'PAYMENT_METHOD_TYPE', 'VISA_CARD', '', 'Visa Card', 1, SYSDATE, 1, SYSDATE); INSERT INTO COMMON_LOOKUP VALUES ( common_lookup_s1.nextval, 'TRANSACTION', 'PAYMENT_METHOD_TYPE', 'MASTER_CARD', '', 'Master Card', 1, SYSDATE, 1, SYSDATE); INSERT INTO COMMON_LOOKUP VALUES ( common_lookup_s1.nextval, 'TRANSACTION', 'PAYMENT_METHOD_TYPE', 'CASH', '', 'Cash', 1, SYSDATE, 1, SYSDATE); INSERT INTO COMMON_LOOKUP VALUES
  • 26. ( common_lookup_s1.nextval, 'RENTAL_ITEM', 'RENTAL_ITEM_TYPE', '1-DAY RENTAL', '', '1-Day Rental', 1, SYSDATE, 1, SYSDATE); INSERT INTO COMMON_LOOKUP VALUES ( common_lookup_s1.nextval, 'RENTAL_ITEM', 'RENTAL_ITEM_TYPE', '3-DAY RENTAL', '', '3-Day Rental', 1, SYSDATE, 1, SYSDATE); INSERT INTO COMMON_LOOKUP VALUES ( common_lookup_s1.nextval, 'RENTAL_ITEM', 'RENTAL_ITEM_TYPE', '5-DAY RENTAL', '', '5-Day Rental', 1, SYSDATE, 1, SYSDATE); -- Format and query output. --COLUMN common_lookup_id FORMAT 9999 HEADING "Lookup|ID #" --COLUMN common_lookup_table FORMAT A18 HEADING "Lookup|Table" --COLUMN common_lookup_column FORMAT A20 HEADING "Lookup|Column" --COLUMN common_lookup_type FORMAT A18 HEADING "Lookup|Type"
  • 27. --COLUMN common_lookup_code FORMAT A8 HEADING "Lookup|Code" --SELECT common_lookup_id --, common_lookup_table --, common_lookup_column --, common_lookup_type --, common_lookup_code --FROM common_lookup; ALTER TABLE system_user ADD CONSTRAINT fk_system_user_3 FOREIGN KEY(system_user_type) REFERENCES common_lookup(common_lookup_id); -- Conditionally drop objects. BEGIN FOR i IN (SELECT null FROM user_tables WHERE table_name = 'MEMBER') LOOP
  • 28. EXECUTE IMMEDIATE 'DROP TABLE member CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'MEMBER_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE member_s1'; END LOOP; END; / -- ------------------------------------------------------------------ -- Create MEMBER table and sequence and seed data. -- ------------------------------------------------------------------ CREATE TABLE member ( member_id NUMBER CONSTRAINT pk_member PRIMARY KEY , member_type NUMBER CONSTRAINT nn_member_1 NOT NULL
  • 29. , account_number VARCHAR2(10) CONSTRAINT nn_member_2 NOT NULL , credit_card_number VARCHAR2(19) CONSTRAINT nn_member_3 NOT NULL , credit_card_type NUMBER CONSTRAINT nn_member_4 NOT NULL , created_by NUMBER CONSTRAINT nn_member_5 NOT NULL , creation_date DATE CONSTRAINT nn_member_6 NOT NULL , last_updated_by NUMBER CONSTRAINT nn_member_7 NOT NULL , last_update_date DATE CONSTRAINT nn_member_8 NOT NULL , CONSTRAINT fk_member_1 FOREIGN KEY(member_type) REFERENCES common_lookup(common_lookup_id) , CONSTRAINT fk_member_2 FOREIGN KEY(credit_card_type) REFERENCES common_lookup(common_lookup_id) , CONSTRAINT fk_member_3 FOREIGN KEY(created_by) REFERENCES system_user(system_user_id)
  • 30. , CONSTRAINT fk_member_4 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id)); CREATE SEQUENCE member_s1 START WITH 1000; -- Conditionally drop objects. BEGIN FOR i IN (SELECT null FROM user_tables WHERE table_name = 'CONTACT') LOOP EXECUTE IMMEDIATE 'DROP TABLE contact CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'CONTACT_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE contact_s1'; END LOOP;
  • 31. END; / -- ------------------------------------------------------------------ -- Create CONTACT table and sequence and seed data. -- ------------------------------------------------------------------ CREATE TABLE contact ( contact_id NUMBER CONSTRAINT pk_contact PRIMARY KEY , member_id NUMBER CONSTRAINT nn_contact_1 NOT NULL , contact_type NUMBER CONSTRAINT nn_contact_2 NOT NULL , last_name VARCHAR2(20) CONSTRAINT nn_contact_3 NOT NULL , first_name VARCHAR2(20) CONSTRAINT nn_contact_4 NOT NULL , middle_name VARCHAR2(20) , created_by NUMBER CONSTRAINT nn_contact_5 NOT NULL
  • 32. , creation_date DATE CONSTRAINT nn_contact_6 NOT NULL , last_updated_by NUMBER CONSTRAINT nn_contact_7 NOT NULL , last_update_date DATE CONSTRAINT nn_contact_8 NOT NULL , CONSTRAINT fk_contact_1 FOREIGN KEY(member_id) REFERENCES member(member_id) , CONSTRAINT fk_contact_2 FOREIGN KEY(contact_type) REFERENCES common_lookup(common_lookup_id) , CONSTRAINT fk_contact_3 FOREIGN KEY(created_by) REFERENCES system_user(system_user_id) , CONSTRAINT fk_contact_4 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id)); CREATE INDEX contact_n1 ON contact(member_id);
  • 33. CREATE SEQUENCE contact_s1 START WITH 1000; -- Conditionally drop objects. BEGIN FOR i IN (SELECT null FROM user_tables WHERE table_name = 'ADDRESS') LOOP EXECUTE IMMEDIATE 'DROP TABLE address CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'ADDRESS_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE address_s1'; END LOOP; END; / -- ------------------------------------------------------------------
  • 34. -- Create ADDRESS table and sequence and seed data. -- ------------------------------------------------------------------ CREATE TABLE address ( address_id NUMBER CONSTRAINT pk_address PRIMARY KEY , contact_id NUMBER CONSTRAINT nn_address_1 NOT NULL , address_type NUMBER CONSTRAINT nn_address_2 NOT NULL , city VARCHAR2(30) CONSTRAINT nn_address_3 NOT NULL , state_province VARCHAR2(30) CONSTRAINT nn_address_4 NOT NULL , postal_code VARCHAR2(20) CONSTRAINT nn_address_5 NOT NULL , created_by NUMBER CONSTRAINT nn_address_6 NOT NULL , creation_date DATE CONSTRAINT nn_address_7 NOT NULL , last_updated_by NUMBER CONSTRAINT nn_address_8 NOT NULL
  • 35. , last_update_date DATE CONSTRAINT nn_address_9 NOT NULL , CONSTRAINT fk_address_1 FOREIGN KEY(contact_id) REFERENCES contact(contact_id) , CONSTRAINT fk_address_2 FOREIGN KEY(address_type) REFERENCES common_lookup(common_lookup_id) , CONSTRAINT fk_address_3 FOREIGN KEY(created_by) REFERENCES system_user(system_user_id) , CONSTRAINT fk_address_4 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id)); CREATE INDEX address_n1 ON address(contact_id); CREATE SEQUENCE address_s1 START WITH 1000; -- Conditionally drop objects. BEGIN
  • 36. FOR i IN (SELECT null FROM user_tables WHERE table_name = 'STREET_ADDRESS') LOOP EXECUTE IMMEDIATE 'DROP TABLE street_address CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'STREET_ADDRESS_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE street_address_s1'; END LOOP; END; / -- ------------------------------------------------------------------ -- Create STREET_ADDRESS table and sequence and seed data. -- ------------------------------------------------------------------
  • 37. CREATE TABLE street_address ( street_address_id NUMBER CONSTRAINT pk_st_address PRIMARY KEY , address_id NUMBER CONSTRAINT nn_st_address_1 NOT NULL , line_number NUMBER CONSTRAINT nn_st_address_2 NOT NULL , street_address VARCHAR2(30) CONSTRAINT nn_st_address_3 NOT NULL , created_by NUMBER CONSTRAINT nn_st_address_4 NOT NULL , creation_date DATE CONSTRAINT nn_st_address_5 NOT NULL , last_updated_by NUMBER CONSTRAINT nn_st_address_6 NOT NULL , last_update_date DATE CONSTRAINT nn_st_address_7 NOT NULL , CONSTRAINT fk_st_address_1 FOREIGN KEY(address_id) REFERENCES address(address_id) , CONSTRAINT fk_st_address_2 FOREIGN KEY(created_by)
  • 38. REFERENCES system_user(system_user_id) , CONSTRAINT fk_st_address_3 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id)); CREATE SEQUENCE street_address_s1 START WITH 1000; -- Conditionally drop objects. BEGIN FOR i IN (SELECT null FROM user_tables WHERE table_name = 'TELEPHONE') LOOP EXECUTE IMMEDIATE 'DROP TABLE telephone CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'TELEPHONE_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE telephone_s1';
  • 39. END LOOP; END; / -- ------------------------------------------------------------------ -- Create TELEPHONE table and sequence and seed data. -- ------------------------------------------------------------------ CREATE TABLE telephone ( telephone_id NUMBER CONSTRAINT pk_telephone PRIMARY KEY , contact_id NUMBER CONSTRAINT nn_telephone_1 NOT NULL , address_id NUMBER CONSTRAINT nn_telephone_2 NOT NULL , telephone_type NUMBER CONSTRAINT nn_telephone_3 NOT NULL , country_code VARCHAR2(3) CONSTRAINT nn_telephone_4 NOT NULL , area_code VARCHAR2(6) CONSTRAINT nn_telephone_5 NOT NULL
  • 40. , telephone_number VARCHAR2(10) CONSTRAINT nn_telephone_6 NOT NULL , created_by NUMBER CONSTRAINT nn_telephone_7 NOT NULL , creation_date DATE CONSTRAINT nn_telephone_8 NOT NULL , last_updated_by NUMBER CONSTRAINT nn_telephone_9 NOT NULL , last_update_date DATE CONSTRAINT nn_telephone_10 NOT NULL , CONSTRAINT fk_telephone_1 FOREIGN KEY(contact_id) REFERENCES contact(contact_id) , CONSTRAINT fk_telephone_2 FOREIGN KEY(telephone_type) REFERENCES common_lookup(common_lookup_id) , CONSTRAINT fk_telephone_3 FOREIGN KEY(created_by) REFERENCES system_user(system_user_id) , CONSTRAINT fk_telephone_4 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id));
  • 41. CREATE INDEX telephone_n1 ON telephone(contact_id,address_id); CREATE INDEX telephone_n2 ON telephone(address_id); CREATE SEQUENCE telephone_s1 START WITH 1000; -- Conditionally drop objects. BEGIN FOR i IN (SELECT null FROM user_tables WHERE table_name = 'RENTAL') LOOP EXECUTE IMMEDIATE 'DROP TABLE rental CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'RENTAL_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE rental_s1';
  • 42. END LOOP; END; / -- ------------------------------------------------------------------ -- Create RENTAL table and sequence and seed data. -- ------------------------------------------------------------------ CREATE TABLE rental ( rental_id NUMBER CONSTRAINT pk_rental PRIMARY KEY , customer_id NUMBER CONSTRAINT nn_rental_1 NOT NULL , check_out_date DATE CONSTRAINT nn_rental_2 NOT NULL , return_date DATE CONSTRAINT nn_rental_3 NOT NULL , created_by NUMBER CONSTRAINT nn_rental_4 NOT NULL , creation_date DATE CONSTRAINT nn_rental_5 NOT NULL
  • 43. , last_updated_by NUMBER CONSTRAINT nn_rental_6 NOT NULL , last_update_date DATE CONSTRAINT nn_rental_7 NOT NULL , CONSTRAINT fk_rental_1 FOREIGN KEY(customer_id) REFERENCES contact(contact_id) , CONSTRAINT fk_rental_2 FOREIGN KEY(created_by) REFERENCES system_user(system_user_id) , CONSTRAINT fk_rental_3 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id)); CREATE SEQUENCE rental_s1 START WITH 1000; -- Conditionally drop objects. BEGIN FOR i IN (SELECT null FROM user_tables
  • 44. WHERE table_name = 'ITEM') LOOP EXECUTE IMMEDIATE 'DROP TABLE item CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'ITEM_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE item_s1'; END LOOP; END; / -- ------------------------------------------------------------------ -- Create ITEM table and sequence and seed data. -- ------------------------------------------------------------------ CREATE TABLE item ( item_id NUMBER CONSTRAINT pk_item PRIMARY KEY
  • 45. , item_barcode VARCHAR2(20) CONSTRAINT nn_item_1 NOT NULL , item_type NUMBER CONSTRAINT nn_item_2 NOT NULL , item_title VARCHAR2(60) CONSTRAINT nn_item_3 NOT NULL , item_subtitle VARCHAR2(60) , item_desc CLOB CONSTRAINT nn_item_4 NOT NULL , item_photo BFILE , item_rating VARCHAR2(8) CONSTRAINT nn_item_5 NOT NULL , item_rating_agency VARCHAR2(4) CONSTRAINT nn_item_6 NOT NULL , item_release_date DATE CONSTRAINT nn_item_7 NOT NULL , created_by NUMBER CONSTRAINT nn_item_8 NOT NULL , creation_date DATE CONSTRAINT nn_item_9 NOT NULL , last_updated_by NUMBER CONSTRAINT nn_item_10 NOT NULL , last_update_date DATE CONSTRAINT nn_item_11 NOT NULL
  • 46. , CONSTRAINT fk_item_1 FOREIGN KEY(item_type) REFERENCES common_lookup(common_lookup_id) , CONSTRAINT fk_item_2 FOREIGN KEY(created_by) REFERENCES system_user(system_user_id) , CONSTRAINT fk_item_3 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id)); CREATE SEQUENCE item_s1 START WITH 1000; -- ------------------------------------------------------------------ -- Create ITEM table triggers for content reference column. -- ------------------------------------------------------------------ -- Check for valid rating in COMMON_LOOKUP table. CREATE OR REPLACE TRIGGER item_t1 BEFORE INSERT OR UPDATE OF item_rating ON item
  • 47. FOR EACH ROW DECLARE -- Declare guard variable. found BOOLEAN := FALSE; -- Declare dynamic cursor. CURSOR get_ratings ( code VARCHAR2 ) IS SELECT common_lookup_code FROM common_lookup WHERE common_lookup_table = 'ITEM' AND common_lookup_column = 'ITEM_RATING' AND common_lookup_code = code; -- Define and set user-defined error. bad_rating EXCEPTION;
  • 48. PRAGMA EXCEPTION_INIT(bad_rating,-20101); BEGIN -- Check for valid rating. FOR i IN get_ratings(:new.item_rating) LOOP found := TRUE; END LOOP; -- Raise exception for invalid rating. IF NOT found THEN RAISE_APPLICATION_ERROR(-20101,'Rating Value not defined in COMMON_LOOKUP table.'); END IF; END item_t1; / -- Conditionally drop objects.
  • 49. BEGIN FOR i IN (SELECT null FROM user_tables WHERE table_name = 'RENTAL_ITEM') LOOP EXECUTE IMMEDIATE 'DROP TABLE rental_item CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'RENTAL_ITEM_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE rental_item_s1'; END LOOP; END; / -- Check for valid rating agency in COMMON_LOOKUP table. CREATE OR REPLACE TRIGGER item_t1
  • 50. BEFORE INSERT OR UPDATE OF item_rating_agency ON item FOR EACH ROW DECLARE -- Declare guard variable. found BOOLEAN := FALSE; -- Declare dynamic cursor. CURSOR get_ratings ( agency VARCHAR2 ) IS SELECT common_lookup_code FROM common_lookup WHERE common_lookup_table = 'ITEM' AND common_lookup_column = 'ITEM_RATING_AGENCY' AND common_lookup_code = agency;
  • 51. -- Define and set user-defined error. bad_rating EXCEPTION; PRAGMA EXCEPTION_INIT(bad_rating,-20102); BEGIN -- Check for valid rating. FOR i IN get_ratings(:new.item_rating_agency) LOOP found := TRUE; END LOOP; -- Raise exception for invalid rating. IF NOT found THEN RAISE_APPLICATION_ERROR(-20102,'Rating Agency Value not defined in COMMON_LOOKUP table.'); END IF; END item_t1; /
  • 52. -- Conditionally drop objects. BEGIN FOR i IN (SELECT null FROM user_tables WHERE table_name = 'RENTAL_ITEM') LOOP EXECUTE IMMEDIATE 'DROP TABLE rental_item CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'RENTAL_ITEM_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE rental_item_s1'; END LOOP; END; /
  • 53. -- ------------------------------------------------------------------ -- Create RENTAL_ITEM table and sequence and seed data. -- ------------------------------------------------------------------ CREATE TABLE rental_item ( rental_item_id NUMBER CONSTRAINT pk_rental_item PRIMARY KEY , rental_id NUMBER CONSTRAINT nn_rental_item_1 NOT NULL , item_id NUMBER CONSTRAINT nn_rental_item_2 NOT NULL , rental_item_price NUMBER CONSTRAINT nn_rental_item_3 NOT NULL , rental_item_type NUMBER CONSTRAINT nn_rental_item_4 NOT NULL , created_by NUMBER CONSTRAINT nn_rental_item_5 NOT NULL , creation_date DATE CONSTRAINT nn_rental_item_6 NOT NULL , last_updated_by NUMBER CONSTRAINT nn_rental_item_7 NOT NULL , last_update_date DATE CONSTRAINT nn_rental_item_8 NOT NULL
  • 54. , CONSTRAINT fk_rental_item_1 FOREIGN KEY(rental_id) REFERENCES rental(rental_id) , CONSTRAINT fk_rental_item_2 FOREIGN KEY(item_id) REFERENCES item(item_id) , CONSTRAINT fk_rental_item_3 FOREIGN KEY(created_by) REFERENCES system_user(system_user_id) , CONSTRAINT fk_rental_item_4 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id)); CREATE SEQUENCE rental_item_s1 START WITH 1000; -- Conditionally drop objects. BEGIN FOR i IN (SELECT null FROM user_tables WHERE table_name = 'PRICE') LOOP
  • 55. EXECUTE IMMEDIATE 'DROP TABLE price CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'PRICE_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE price_s1'; END LOOP; END; / -- ------------------------------------------------------------------ -- Create PRICE table and sequence and seed data. -- ------------------------------------------------------------------ CREATE TABLE price ( price_id NUMBER CONSTRAINT pk_price PRIMARY KEY , item_id NUMBER CONSTRAINT
  • 56. nn_price_1 NOT NULL , price_type NUMBER CONSTRAINT nn_price_2 NOT NULL , active_flag VARCHAR2(1) CONSTRAINT nn_price_3 NOT NULL , amount NUMBER CONSTRAINT nn_price_4 NOT NULL , start_date DATE CONSTRAINT nn_price_5 NOT NULL , end_date DATE , created_by NUMBER CONSTRAINT nn_price_6 NOT NULL , creation_date DATE CONSTRAINT nn_price_7 NOT NULL , last_updated_by NUMBER CONSTRAINT nn_price_8 NOT NULL , last_update_date DATE CONSTRAINT nn_price_9 NOT NULL , CONSTRAINT fk_price_1 FOREIGN KEY(item_id) REFERENCES item(item_id) , CONSTRAINT fk_price_2 FOREIGN KEY(price_type)
  • 57. REFERENCES common_lookup(common_lookup_id) , CONSTRAINT fk_price_3 FOREIGN KEY(created_by) REFERENCES system_user(system_user_id) , CONSTRAINT fk_price_4 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id)); CREATE SEQUENCE price_s1 START WITH 1000; -- ------------------------------------------------------------------ -- Seed PRICE data in COMMON_LOOKUP table. -- ------------------------------------------------------------------ INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'PRICE','ACTIVE_FLAG','YES','Y', 'Yes' , 1, SYSDATE, 1, SYSDATE);
  • 58. INSERT INTO common_lookup VALUES ( common_lookup_s1.nextval,'PRICE','ACTIVE_FLAG','NO','N',' Yes' , 1, SYSDATE, 1, SYSDATE); INSERT INTO common_lookup ( common_lookup_id -- 1 , common_lookup_table -- 2 , common_lookup_column -- 3 , common_lookup_type -- 4 , common_lookup_code -- 5 , common_lookup_meaning -- 6 , created_by -- 7 , creation_date -- 8 , last_updated_by -- 9 , last_update_date) -- 10
  • 59. SELECT common_lookup_s1.nextval -- 1 (id) , 'PRICE' -- 2 (table) , 'AMOUNT' -- 3 (column) , il.type -- 4 (type) , TO_CHAR(il.fabricated) -- 5 (code) , il.meaning -- 6 (meaning) , 1 -- 7 (c_id) , SYSDATE -- 8 (c_date) , 1 -- 9 (u_id) , SYSDATE -- 10 (u_date) FROM dual CROSS JOIN (SELECT 'New' AS status , 1 AS fabricated , '1-DAY RENTAL' type , '1-Day Rental' meaning FROM dual UNION ALL SELECT 'New' AS type , 3 AS fabricated , '3-DAY RENTAL' type
  • 60. , '3-Day Rental' meaning FROM dual UNION ALL SELECT 'New' AS type , 5 AS fabricated , '5-DAY RENTAL' type , '5-Day Rental' meaning FROM dual) il; -- Conditionally drop objects. BEGIN FOR i IN (SELECT null FROM user_tables WHERE table_name = 'TRANSACTION') LOOP EXECUTE IMMEDIATE 'DROP TABLE transaction CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'TRANSACTION_S1') LOOP
  • 61. EXECUTE IMMEDIATE 'DROP SEQUENCE transaction_s1'; END LOOP; END; / -- ------------------------------------------------------------------ -- Create TRANSACTION table and sequence and seed data. -- ------------------------------------------------------------------ CREATE TABLE transaction ( transaction_id NUMBER CONSTRAINT pk_transaction PRIMARY KEY , transaction_account VARCHAR2(20) CONSTRAINT nn_transaction_1 NOT NULL , transaction_type NUMBER CONSTRAINT nn_transaction_2 NOT NULL , transaction_date DATE CONSTRAINT nn_transaction_3 NOT NULL , transaction_amount NUMBER CONSTRAINT nn_transaction_4 NOT NULL
  • 62. , rental_id NUMBER CONSTRAINT nn_transaction_5 NOT NULL , payment_method NUMBER CONSTRAINT nn_transaction_6 NOT NULL , payment_account_number VARCHAR2(20) CONSTRAINT nn_transaction_7 NOT NULL , created_by NUMBER CONSTRAINT nn_transaction_8 NOT NULL , creation_date DATE CONSTRAINT nn_transaction_9 NOT NULL , last_updated_by NUMBER CONSTRAINT nn_transaction_10 NOT NULL , last_update_date DATE CONSTRAINT nn_transaction_11 NOT NULL , CONSTRAINT fk_transaction_1 FOREIGN KEY(rental_id) REFERENCES rental(rental_id) , CONSTRAINT fk_transaction_2 FOREIGN KEY(transaction_type) REFERENCES common_lookup(common_lookup_id) , CONSTRAINT fk_transaction_3 FOREIGN KEY(created_by) REFERENCES system_user(system_user_id)
  • 63. , CONSTRAINT fk_transaction_4 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id)); CREATE SEQUENCE transaction_s1 START WITH 1000; -- Conditionally drop objects. BEGIN FOR i IN (SELECT null FROM user_tables WHERE table_name = 'CALENDAR') LOOP EXECUTE IMMEDIATE 'DROP TABLE calendar CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT null FROM user_sequences WHERE sequence_name = 'CALENDAR_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE calendar_s1'; END LOOP;
  • 64. END; / -- ------------------------------------------------------------------ -- Create CALENDAR table and sequence and seed data. -- ------------------------------------------------------------------ CREATE TABLE calendar ( calendar_id NUMBER CONSTRAINT pk_calendar PRIMARY KEY , calendar_month_name VARCHAR2(3) CONSTRAINT nn_calendar_1 NOT NULL , calendar_full_month_name VARCHAR2(9) CONSTRAINT nn_calendar_2 NOT NULL , start_date DATE CONSTRAINT nn_calendar_3 NOT NULL , end_date DATE CONSTRAINT nn_calendar_4 NOT NULL , created_by NUMBER CONSTRAINT nn_calendar_5 NOT NULL , creation_date DATE CONSTRAINT
  • 65. nn_calendar_6 NOT NULL , last_updated_by NUMBER CONSTRAINT nn_calendar_7 NOT NULL , last_update_date DATE CONSTRAINT nn_calendar_8 NOT NULL , CONSTRAINT fk_calendar_1 FOREIGN KEY(created_by) REFERENCES system_user(system_user_id) , CONSTRAINT fk_calendar_2 FOREIGN KEY(last_updated_by) REFERENCES system_user(system_user_id)); CREATE SEQUENCE calendar_s1 START WITH 1000; -- Seed the Calendar table. DECLARE -- Define local variables. start_date DATE; end_date DATE;
  • 66. -- Define local array types. TYPE number_list IS TABLE OF NUMBER; TYPE month_list IS TABLE OF VARCHAR2(3); TYPE name_list IS TABLE OF VARCHAR2(9); -- Define and initialize array for month ending date. end_day NUMBER_LIST := number_list(31,28,31 ,30,31,30 ,31,31,30 ,31,30,31); -- Define and initial short and long month names. months MONTH_LIST := month_list('JAN','FEB','MAR' ,'APR','MAY','JUN' ,'JUL','AUG','SEP' ,'OCT','NOV','DEC'); month_names NAME_LIST := name_list('January','February','March'
  • 67. ,'April','May','June' ,'July','August','September' ,'October','November','December'); -- Define and initialize years. years NUMBER_LIST := number_list(1996,1997,1998,1999,2000 ,2001,2002,2003,2004,2005 ,2006,2007,2008,2009,2010 ,2011,2012,2013,2014,2015 ,2016,2017,2018,2019,2020); BEGIN -- Loop through years and then months. FOR i IN 1..years.COUNT LOOP FOR j IN 1..months.COUNT LOOP
  • 68. -- Set month starting date. start_date := TO_DATE('01'||months(j)||years(i),'DD-MON- YYYY'); -- Check, modify leap year February, and set month ending date. IF ((MOD(years(i) , 4) = 0) AND (j = 2)) THEN end_date := TO_DATE((end_day(j) + 1)||'-'||months(j)||'- '||years(i),'DD-MON-YYYY'); ELSE end_date := TO_DATE((end_day(j))||'-'||months(j)||'- '||years(i),'DD-MON-YYYY'); END IF; -- Insert month into calendar. INSERT INTO calendar VALUES ( calendar_s1.nextval , months(j)
  • 69. , month_names(j) , start_date , end_date , 1,SYSDATE,1,SYSDATE); END LOOP; END LOOP; END; / /* -- ------------------------------------------------------------------ -- Insert DBA values in SYSTEM_USER table. -- ------------------------------------------------------------------ */ SELECT 'INSERT DBAs IN SYSTEM_USER' AS "Section Header" FROM dual;
  • 70. INSERT INTO system_user ( system_user_id , system_user_name , system_user_group_id , system_user_type , last_name , first_name , created_by , creation_date , last_updated_by , last_update_date) VALUES ( 2,'DBA', 2, 1,'Adams','Samuel', 1, SYSDATE, 1, SYSDATE); INSERT INTO system_user ( system_user_id
  • 71. , system_user_name , system_user_group_id , system_user_type , last_name , first_name , created_by , creation_date , last_updated_by , last_update_date) VALUES ( 3,'DBA', 2, 1,'Henry','Patrick', 1, SYSDATE, 1, SYSDATE); INSERT INTO system_user ( system_user_id , system_user_name , system_user_group_id , system_user_type
  • 72. , last_name , first_name , created_by , creation_date , last_updated_by , last_update_date) VALUES ( 4,'DBA', 2, 1,'Puri','Manmohan', 1, SYSDATE, 1, SYSDATE); INSERT INTO system_user ( system_user_id , system_user_name , system_user_group_id , system_user_type , last_name , first_name , created_by
  • 73. , creation_date , last_updated_by , last_update_date) VALUES ( 5,'DBA', 2, 1,'Fullerton','Gail', 1, SYSDATE, 1, SYSDATE); -- ------------------------------------------------------------------ -- This seeds rows in a dependency chain, including the MEMBER, CONTACT -- ADDRESS, and TELEPHONE tables. -- ------------------------------------------------------------------ -- Insert record set #1. -- ------------------------------------------------------------------ SELECT 'INSERT MEMBER, CONTACT, ADDRESS, ETC' AS "Section Header" FROM dual; INSERT INTO member VALUES ( member_s1.nextval ,(SELECT common_lookup_id
  • 74. FROM common_lookup WHERE common_lookup_table = 'MEMBER' AND common_lookup_column = 'MEMBER_TYPE' AND common_lookup_type = 'GROUP') ,'B293-71445' ,'1111-2222-3333-4444' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'MEMBER' AND common_lookup_column = 'CREDIT_CARD_TYPE' AND common_lookup_type = 'DISCOVER_CARD') , 2, SYSDATE, 2, SYSDATE); INSERT INTO contact ( contact_id , member_id , contact_type , first_name
  • 75. , middle_name , last_name , created_by , creation_date , last_updated_by , last_update_date ) VALUES ( contact_s1.nextval , member_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'CONTACT' AND common_lookup_column = 'CONTACT_TYPE' AND common_lookup_type = 'CUSTOMER') ,'Randi','','Winn' , 2, SYSDATE, 2, SYSDATE); INSERT INTO address VALUES
  • 76. ( address_s1.nextval , contact_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'ADDRESS' AND common_lookup_column = 'ADDRESS_TYPE' AND common_lookup_type = 'HOME') ,'San Jose','CA','95192' , 2, SYSDATE, 2, SYSDATE); INSERT INTO street_address VALUES ( street_address_s1.nextval , address_s1.currval , 1 ,'10 El Camino Real' , 2, SYSDATE, 2, SYSDATE); INSERT INTO telephone VALUES
  • 77. ( telephone_s1.nextval , address_s1.currval , contact_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'TELEPHONE' AND common_lookup_column = 'TELEPHONE_TYPE' AND common_lookup_type = 'HOME') ,'USA','408','111-1111' , 2, SYSDATE, 2, SYSDATE); INSERT INTO contact ( contact_id , member_id , contact_type , first_name , middle_name , last_name
  • 78. , created_by , creation_date , last_updated_by , last_update_date ) VALUES ( contact_s1.nextval , member_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'CONTACT' AND common_lookup_column = 'CONTACT_TYPE' AND common_lookup_type = 'CUSTOMER') ,'Brian','','Winn' , 2, SYSDATE, 2, SYSDATE); INSERT INTO address VALUES ( address_s1.nextval , contact_s1.currval
  • 79. ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'ADDRESS' AND common_lookup_column = 'ADDRESS_TYPE' AND common_lookup_type = 'HOME') ,'San Jose','CA','95192' , 2, SYSDATE, 2, SYSDATE); INSERT INTO street_address VALUES ( street_address_s1.nextval , address_s1.currval , 1 ,'10 El Camino Real' , 2, SYSDATE, 2, SYSDATE); INSERT INTO telephone VALUES ( telephone_s1.nextval , address_s1.currval
  • 80. , contact_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'TELEPHONE' AND common_lookup_column = 'TELEPHONE_TYPE' AND common_lookup_type = 'HOME') ,'USA','408','111-1111' , 2, SYSDATE, 2, SYSDATE); -- ------------------------------------------------------------------ -- Insert record set #2. -- ------------------------------------------------------------------ INSERT INTO member VALUES ( member_s1.nextval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'MEMBER' AND common_lookup_column = 'MEMBER_TYPE'
  • 81. AND common_lookup_type = 'GROUP') ,'B293-71446' ,'2222-3333-4444-5555' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'MEMBER' AND common_lookup_column = 'CREDIT_CARD_TYPE' AND common_lookup_type = 'DISCOVER_CARD') , 2, SYSDATE, 2, SYSDATE); INSERT INTO contact ( contact_id , member_id , contact_type , first_name , middle_name , last_name , created_by
  • 82. , creation_date , last_updated_by , last_update_date ) VALUES ( contact_s1.nextval , member_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'CONTACT' AND common_lookup_column = 'CONTACT_TYPE' AND common_lookup_type = 'CUSTOMER') ,'Oscar','','Vizquel' , 2, SYSDATE, 2, SYSDATE); INSERT INTO address VALUES ( address_s1.nextval , contact_s1.currval ,(SELECT common_lookup_id
  • 83. FROM common_lookup WHERE common_lookup_table = 'ADDRESS' AND common_lookup_column = 'ADDRESS_TYPE' AND common_lookup_type = 'HOME') ,'San Jose','CA','95192' , 2, SYSDATE, 2, SYSDATE); INSERT INTO street_address VALUES ( street_address_s1.nextval , address_s1.currval , 1 ,'12 El Camino Real' , 2, SYSDATE, 2, SYSDATE); INSERT INTO telephone VALUES ( telephone_s1.nextval , address_s1.currval , contact_s1.currval
  • 84. ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'TELEPHONE' AND common_lookup_column = 'TELEPHONE_TYPE' AND common_lookup_type = 'HOME') ,'USA','408','222-2222' , 2, SYSDATE, 2, SYSDATE); INSERT INTO contact ( contact_id , member_id , contact_type , first_name , middle_name , last_name , created_by , creation_date , last_updated_by
  • 85. , last_update_date ) VALUES ( contact_s1.nextval , member_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'CONTACT' AND common_lookup_column = 'CONTACT_TYPE' AND common_lookup_type = 'CUSTOMER') ,'Doreen','','Vizquel' , 2, SYSDATE, 2, SYSDATE); INSERT INTO address VALUES ( address_s1.nextval , contact_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'ADDRESS'
  • 86. AND common_lookup_column = 'ADDRESS_TYPE' AND common_lookup_type = 'HOME') ,'San Jose','CA','95192' , 2, SYSDATE, 2, SYSDATE); INSERT INTO street_address VALUES ( street_address_s1.nextval , address_s1.currval , 1 ,'12 El Camino Real' , 2, SYSDATE, 2, SYSDATE); INSERT INTO telephone VALUES ( telephone_s1.nextval , address_s1.currval , contact_s1.currval ,(SELECT common_lookup_id FROM common_lookup
  • 87. WHERE common_lookup_table = 'TELEPHONE' AND common_lookup_column = 'TELEPHONE_TYPE' AND common_lookup_type = 'HOME') ,'USA','408','222-2222' , 2, SYSDATE, 2, SYSDATE); -- ------------------------------------------------------------------ -- Insert record set #3. -- ------------------------------------------------------------------ INSERT INTO member VALUES ( member_s1.nextval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'MEMBER' AND common_lookup_column = 'MEMBER_TYPE' AND common_lookup_type = 'GROUP') ,'B293-71447'
  • 88. ,'3333-4444-5555-6666' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'MEMBER' AND common_lookup_column = 'CREDIT_CARD_TYPE' AND common_lookup_type = 'DISCOVER_CARD') , 2, SYSDATE, 2, SYSDATE); INSERT INTO contact ( contact_id , member_id , contact_type , first_name , middle_name , last_name , created_by , creation_date , last_updated_by
  • 89. , last_update_date ) VALUES ( contact_s1.nextval , member_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'CONTACT' AND common_lookup_column = 'CONTACT_TYPE' AND common_lookup_type = 'CUSTOMER') ,'Meaghan','','Sweeney' , 2, SYSDATE, 2, SYSDATE); INSERT INTO address VALUES ( address_s1.nextval , contact_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'ADDRESS'
  • 90. AND common_lookup_column = 'ADDRESS_TYPE' AND common_lookup_type = 'HOME') ,'San Jose','CA','95192' , 2, SYSDATE, 2, SYSDATE); INSERT INTO street_address VALUES ( street_address_s1.nextval , address_s1.currval , 1 ,'14 El Camino Real' , 2, SYSDATE, 2, SYSDATE); INSERT INTO telephone VALUES ( telephone_s1.nextval , address_s1.currval , contact_s1.currval ,(SELECT common_lookup_id FROM common_lookup
  • 91. WHERE common_lookup_table = 'TELEPHONE' AND common_lookup_column = 'TELEPHONE_TYPE' AND common_lookup_type = 'HOME') ,'USA','408','333-3333' , 2, SYSDATE, 2, SYSDATE); INSERT INTO contact ( contact_id , member_id , contact_type , first_name , middle_name , last_name , created_by , creation_date , last_updated_by , last_update_date ) VALUES
  • 92. ( contact_s1.nextval , member_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'CONTACT' AND common_lookup_column = 'CONTACT_TYPE' AND common_lookup_type = 'CUSTOMER') ,'Matthew','','Sweeney' , 2, SYSDATE, 2, SYSDATE); INSERT INTO address VALUES ( address_s1.nextval , contact_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'ADDRESS' AND common_lookup_column = 'ADDRESS_TYPE' AND common_lookup_type = 'HOME')
  • 93. ,'San Jose','CA','95192' , 2, SYSDATE, 2, SYSDATE); INSERT INTO street_address VALUES ( street_address_s1.nextval , address_s1.currval , 1 ,'14 El Camino Real' , 2, SYSDATE, 2, SYSDATE); INSERT INTO telephone VALUES ( telephone_s1.nextval , address_s1.currval , contact_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'TELEPHONE' AND common_lookup_column = 'TELEPHONE_TYPE'
  • 94. AND common_lookup_type = 'HOME') ,'USA','408','333-3333' , 2, SYSDATE, 2, SYSDATE); INSERT INTO contact ( contact_id , member_id , contact_type , first_name , middle_name , last_name , created_by , creation_date , last_updated_by , last_update_date ) VALUES ( contact_s1.nextval , member_s1.currval
  • 95. ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'CONTACT' AND common_lookup_column = 'CONTACT_TYPE' AND common_lookup_type = 'CUSTOMER') ,'Ian','M','Sweeney' , 2, SYSDATE, 2, SYSDATE); INSERT INTO address VALUES ( address_s1.nextval , contact_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'ADDRESS' AND common_lookup_column = 'ADDRESS_TYPE' AND common_lookup_type = 'HOME') ,'San Jose','CA','95192' , 2, SYSDATE, 2, SYSDATE);
  • 96. INSERT INTO street_address VALUES ( street_address_s1.nextval , address_s1.currval , 1 ,'14 El Camino Real' , 2, SYSDATE, 2, SYSDATE); INSERT INTO telephone VALUES ( telephone_s1.nextval , address_s1.currval , contact_s1.currval ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'TELEPHONE' AND common_lookup_column = 'TELEPHONE_TYPE' AND common_lookup_type = 'HOME') ,'USA','408','333-3333'
  • 97. , 2, SYSDATE, 2, SYSDATE); /* -- ------------------------------------------------------------------ -- Insert values in ITEM table. -- ------------------------------------------------------------------ */ SELECT 'INSERT ITEM' AS "Section Header" FROM dual; INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0001US8F8' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Around the World in 80 Days' ,'Two-Disc Special Edition' , empty_clob() , NULL
  • 98. ,'NR' ,'MPAA' ,'18-MAY-2004' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0002S64TQ' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Around the World in 80 Days' ,'' , empty_clob() , NULL ,'PG' ,'MPAA' ,'02-NOV-2004'
  • 99. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000MNP2KI' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Casino Royale' ,'' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'13-MAR-2007' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 100. ( item_s1.nextval ,'ASIN: B000MNP2K8' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Casino Royale' ,'' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'13-MAR-2007' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00005JLBE' ,(SELECT common_lookup_id
  • 101. FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Die Another Day' ,'' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'03-JUN-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000LY9CMC' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Die Another Day'
  • 102. ,'2-Disc Ultimate Version' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'03-JUN-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00008S2SF' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Die Another Day' ,'' , empty_clob() , NULL
  • 103. ,'PG-13' ,'MPAA' ,'03-JUN-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00000K0E5' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Golden Eye' ,'Special Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'22-OCT-2002'
  • 104. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000M53GM2' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Golden Eye' ,'' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'06-FEB-2007' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 105. ( item_s1.nextval ,'ASIN: 6304916558' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Tomorrow Never Dies' ,'' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'13-MAY-1998' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00000K0EA' ,(SELECT common_lookup_id
  • 106. FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Tomorrow Never Dies' ,'Special Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'22-OCT-2002' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: 6305784922' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The World Is Not Enough'
  • 107. ,'' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'16-MAY-2000' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000NIBURQ' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The World Is Not Enough' ,'' , empty_clob() , NULL
  • 108. ,'PG-13' ,'MPAA' ,'22-MAY-2007' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00003CX95' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Brave Heart' ,'' , empty_clob() , NULL ,'R' ,'MPAA' ,'29-AUG-2000'
  • 109. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: 6304712944' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Camelot' ,'' , empty_clob() , NULL ,'G' ,'MPAA' ,'29-JUL-1998' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 110. ( item_s1.nextval ,'ASIN: B000B5XOZ2' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Christmas Carol' ,'' , empty_clob() , NULL ,'NR' ,'MPAA' ,'08-NOV-2005' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00000K3CJ' ,(SELECT common_lookup_id
  • 111. FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Christmas Carol' ,'' , empty_clob() , NULL ,'PG' ,'MPAA' ,'05-OCT-1999' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0000AQS5D' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Scrooge'
  • 112. ,'' , empty_clob() , NULL ,'G' ,'MPAA' ,'23-SEP-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: 6305127719' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Clear and Present Danger' ,'' , empty_clob() , NULL
  • 113. ,'PG-13' ,'MPAA' ,'21-OCT-1998' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00008K76V' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Clear and Present Danger' ,'Special Collector''s Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'06-MAY-2003'
  • 114. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00003CXI1' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Harry Potter and the Sorcer''s Stone' ,'Two-Disc Special Edition' , empty_clob() , NULL ,'PG' ,'MPAA' ,'28-MAY-2002' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 115. ( item_s1.nextval ,'ASIN: B000062TU1' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Harry Potter and the Sorcer''s Stone' ,'Full Screen Edition' , empty_clob() , NULL ,'PG' ,'MPAA' ,'28-MAY-2002' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00008DDXC' ,(SELECT common_lookup_id
  • 116. FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Harry Potter and the Chamber of Secrets' ,'Two-Disc Special Edition' , empty_clob() , NULL ,'PG' ,'MPAA' ,'11-APR-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00008DDXL' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Harry Potter and the Chamber of Secrets'
  • 117. ,'Full Screen Edition' , empty_clob() , NULL ,'PG' ,'MPAA' ,'11-APR-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00005JMAH' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Harry Potter and the Prisoner of Azkaban' ,'Two-Disc Special Edition' , empty_clob() , NULL
  • 118. ,'PG' ,'MPAA' ,'23-NOV-2004' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0002TT0NW' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Harry Potter and the Prisoner of Azkaban' ,'2-Disc Full Screen Edition' , empty_clob() , NULL ,'PG' ,'MPAA' ,'23-NOV-2004'
  • 119. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0002VB24K' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Harry Potter and the Chamber of Secrets' ,'' , empty_clob() , NULL ,'PG' ,'MPAA' ,'23-NOV-2004' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 120. ( item_s1.nextval ,'ASIN: B000E6EK2Y' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Harry Potter and the Goblet of Fire' ,'Widescreen Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'07-MAR-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000E6EK38' ,(SELECT common_lookup_id
  • 121. FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Harry Potter and the Goblet of Fire' ,'Full Screen Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'07-MAR-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000E6EK3S' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Harry Potter and the Goblet of Fire'
  • 122. ,'Two-Disc Special Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'07-MAR-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000E6EZ3Z' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Harry Potter and the Order of the Phoenix' ,'Widescreen Edition' , empty_clob() , NULL
  • 123. ,'PG-13' ,'MPAA' ,'11-DEC-2007' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: 6305182043' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Hunt for Red October' ,'' , empty_clob() , NULL ,'PG' ,'MPAA' ,'01-DEC-1998'
  • 124. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00008K76U' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Hunt for Red October' ,'Special Collector''s Edition' , empty_clob() , NULL ,'PG' ,'MPAA' ,'06-MAY-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 125. ( item_s1.nextval ,'ASIN: B0002YLCG0' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'King Arthur - The Director''s Cut' ,'Wide Screen Edition' , empty_clob() , NULL ,'R' ,'MPAA' ,'21-DEC-2004' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0002YLCFQ' ,(SELECT common_lookup_id
  • 126. FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'King Arthur' ,'PG-13 Full Screen Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'21-DEC-2004' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0002YLCG0' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'King Arthur - The Director''s Cut'
  • 127. ,'Wide Screen Edition' , empty_clob() , NULL ,'R' ,'MPAA' ,'21-DEC-2004' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00003CWT6' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Lord of the Rings - Fellowship of the Ring' ,'Widescreen Edition' , empty_clob() , NULL
  • 128. ,'PG-13' ,'MPAA' ,'06-AUG-2002' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000065U3Q' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'The Lord of the Rings - Fellowship of the Ring' ,'Fullscreen Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'06-AUG-2002'
  • 129. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000067DNF' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Lord of the Rings - Fellowship of the Ring' ,'Platinum Series Special Extended Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'12-NOV-2002' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 130. ( item_s1.nextval ,'ASIN: B00005JKZV' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Lord of the Rings - Two Towers' ,'Widescreen Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'26-AUG-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00009APK1' ,(SELECT common_lookup_id
  • 131. FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'The Lord of the Rings - Two Towers' ,'Fullscreen Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'26-AUG-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00009TB5G' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Lord of the Rings - Two Towers'
  • 132. ,'Platinum Series Special Extended Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'18-NOV-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00005JKZY' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Lord of the Rings - The Return of the King' ,'Widescreen Edition' , empty_clob() , NULL
  • 133. ,'PG-13' ,'MPAA' ,'25-MAY-2004' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0001US8E4' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'The Lord of the Rings - The Return of the King' ,'Fullscreen Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'25-MAY-2004'
  • 134. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000634DCW' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Lord of the Rings - The Return of the King' ,'Platinum Series Special Extended Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'14-DEC-2004' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 135. ( item_s1.nextval ,'ASIN: 6305222878' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Patriot Games' ,'' , empty_clob() , NULL ,'R' ,'MPAA' ,'15-DEC-1998' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00008K76W' ,(SELECT common_lookup_id
  • 136. FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Patriot Games' ,'Special Collector''s Edition' , empty_clob() , NULL ,'R' ,'MPAA' ,'06-MAY-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00005JM5E' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Pirates of the Caribbean - The Curse of the Black Pearl'
  • 137. ,'Two-Disc Collector''s Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'02-DEC-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0002XL342' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Pirates of the Caribbean - The Curse of the Black Pearl' ,'Three-Disc Special Edition' , empty_clob() , NULL
  • 138. ,'PG-13' ,'MPAA' ,'02-NOV-2004' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0000C6DWS' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Pirates of the Caribbean - The Curse of the Black Pearl' ,'' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'02-DEC-2003'
  • 139. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000I0RQVI' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Pirates of the Caribbean - Dead Man''s Chest' ,'' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'05-DEC-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 140. ( item_s1.nextval ,'ASIN: B00005JP0F' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Pirates of the Caribbean - Dead Man''s Chest' ,'Two-Disc Collector''s Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'05-DEC-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0R0I0RDEI' ,(SELECT common_lookup_id
  • 141. FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Pirates of the Caribbean - At World''s End' ,'' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'05-DEC-2007' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0R0I0RRES' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Pirates of the Caribbean - At World''s End'
  • 142. ,'Two-Disc Collector''s Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'05-DEC-2007' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00009Q98M' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Indiana Jones and the Raiders of the Lost Ark' ,'Widescreen Edition' , empty_clob() , NULL
  • 143. ,'PG' ,'MPAA' ,'20-FEB-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000F21K66' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Indiana Jones and the Raiders of the Lost Ark' ,'Fullscreen Edition' , empty_clob() , NULL ,'PG' ,'MPAA' ,'20-FEB-2003'
  • 144. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000F7OMZ2' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Indiana Jones and the Temple of Doom' ,'Widescreen Edition' , empty_clob() , NULL ,'PG' ,'MPAA' ,'20-FEB-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 145. ( item_s1.nextval ,'ASIN: B000F7OMZ3' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Indiana Jones and the Temple of Doom' ,'Fullscreen Edition' , empty_clob() , NULL ,'PG' ,'MPAA' ,'20-FEB-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000F7OPCC' ,(SELECT common_lookup_id
  • 146. FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Indiana Jones and the Last Crusade' ,'Widescreen Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'20-FEB-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000F7OPCR' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Indiana Jones and the Last Crusade'
  • 147. ,'Fullscreen Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'20-FEB-2003' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00005JKCH' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Spider-Man' ,'Widescreen Special Edition' , empty_clob() , NULL
  • 148. ,'PG-13' ,'MPAA' ,'01-NOV-2002' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00006F2TV' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Spider-Man' ,'Fullscreen Special Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'01-NOV-2002'
  • 149. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00005JMQW' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Spider-Man 2' ,'Widescreen Special Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'30-NOV-2004' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 150. ( item_s1.nextval ,'ASIN: B0002XK186' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Spider-Man 2' ,'Fullscreen Special Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'30-NOV-2004' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: C00005JMQW' ,(SELECT common_lookup_id
  • 151. FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Spider-Man 3' ,'Widescreen Special Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'30-NOV-2007' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: CB0002XK186' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Spider-Man 3'
  • 152. ,'Fullscreen Special Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'30-NOV-2007' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00003CX5P' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Star Wars - Episode I' ,'The Phantom Menace' , empty_clob() , NULL
  • 153. ,'PG' ,'MPAA' ,'22-MAR-2005' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00006HBUJ' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Star Wars - Episode II' ,'Attack of the Clones' , empty_clob() , NULL ,'PG' ,'MPAA' ,'22-MAR-2005'
  • 154. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00006HBUI' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Star Wars - Episode II' ,'Attack of the Clones' , empty_clob() , NULL ,'PG' ,'MPAA' ,'22-MAR-2005' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 155. ( item_s1.nextval ,'ASIN: B00005JLXH' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Star Wars - Episode III' ,'Revenge of the Sith' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'01-NOV-2005' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00006HBUI' ,(SELECT common_lookup_id
  • 156. FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Star Wars - Episode III' ,'Revenge of the Sith' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'01-NOV-2005' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0006VIE4C' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Star Wars - Episode IV'
  • 157. ,'A New Hope' , empty_clob() , NULL ,'PG' ,'MPAA' ,'12-AUG-2005' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0236VIE4D' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Star Wars - Episode IV' ,'A New Hope' , empty_clob() , NULL
  • 158. ,'PG' ,'MPAA' ,'12-AUG-2005' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0006VIXGQ' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Star Wars - Episode V' ,'The Empire Strikes Back' , empty_clob() , NULL ,'PG' ,'MPAA' ,'12-AUG-2005'
  • 159. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0026VJLGD' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Star Wars - Episode V' ,'The Empire Strikes Back' , empty_clob() , NULL ,'PG' ,'MPAA' ,'12-AUG-2005' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 160. ( item_s1.nextval ,'ASIN: B00076SCPW' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Star Wars - Episode VI' ,'Return of the Jedi' , empty_clob() , NULL ,'PG' ,'MPAA' ,'12-AUG-2005' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00276LJKZ' ,(SELECT common_lookup_id
  • 161. FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Star Wars - Episode VI' ,'Return of the Jedi' , empty_clob() , NULL ,'PG' ,'MPAA' ,'12-AUG-2005' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00005JL8F' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Sum of All Fears'
  • 162. ,'Special Collector''s Edition' , empty_clob() , NULL ,'PG-13' ,'MPAA' ,'29-OCT-2002' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00004XPPG' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Patriot' ,'Special Edition' , empty_clob() , NULL
  • 163. ,'R' ,'MPAA' ,'24-OCT-2000' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000ELL1S0' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'The Patriot' ,'Unrated Extended Cut' , empty_clob() , NULL ,'NR' ,'MPAA' ,'25-APR-2006'
  • 164. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000068TPN' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'We Were Soldiers' ,'' , empty_clob() , NULL ,'R' ,'MPAA' ,'20-AUG-2002' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 165. ( item_s1.nextval ,'ASIN: B000E8M0VA' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'DVD_WIDE_SCREEN') ,'Chronicles of Narnia - The Lion, the Witch and the Wardrobe' ,'Widescreen Edition' , empty_clob() , NULL ,'PG' ,'MPAA' ,'04-APR-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00005JO1X' ,(SELECT common_lookup_id
  • 166. FROM common_lookup WHERE common_lookup_type = 'DVD_FULL_SCREEN') ,'Chronicles of Narnia - The Lion, the Witch and the Wardrobe' ,'Fullscreen Edition' , empty_clob() , NULL ,'PG' ,'MPAA' ,'04-APR-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0009EK534' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'GAMECUBE') ,'Chronicles of Narnia - The Lion, the Witch and the Wardrobe'
  • 167. ,'' , empty_clob() , NULL ,'T' ,'ESRB' ,'15-JUN-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0009ELZXI' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'PLAYSTATION2') ,'Chronicles of Narnia - The Lion, the Witch and the Wardrobe' ,'' , empty_clob() , NULL
  • 168. ,'T' ,'ESRB' ,'15-JUN-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B0009EP9DU' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'XBOX') ,'Chronicles of Narnia - The Lion, the Witch and the Wardrobe' ,'' , empty_clob() , NULL ,'T' ,'ESRB' ,'15-JUN-2006'
  • 169. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000930DPU' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'GAMECUBE') ,'Harry Potter: Goblet of Fire' ,'' , empty_clob() , NULL ,'E10+' ,'ESRB' ,'15-JUN-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES
  • 170. ( item_s1.nextval ,'ASIN: B000930DQ4' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'PLAYSTATION2') ,'Harry Potter: Goblet of Fire' ,'' , empty_clob() , NULL ,'E10+' ,'ESRB' ,'15-JUN-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000930DQE' ,(SELECT common_lookup_id
  • 171. FROM common_lookup WHERE common_lookup_type = 'XBOX') ,'Harry Potter: Goblet of Fire' ,'' , empty_clob() , NULL ,'E10+' ,'ESRB' ,'15-JUN-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000930DPU' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'GAMECUBE') ,'Pirates of the Caribbean'
  • 172. ,'' , empty_clob() , NULL ,'T' ,'ESRB' ,'15-JUN-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000FWAGNY' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'PLAYSTATION2') ,'Pirates of the Caribbean' ,'The Legend of Jack Sparrow' , empty_clob() , NULL
  • 173. ,'T' ,'ESRB' ,'27-JUN-2006' , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B00008V6TF' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'XBOX') ,'Pirates of the Caribbean' ,'' , empty_clob() , NULL ,'T' ,'ESRB' ,'22-MAY-2007'
  • 174. , 3, SYSDATE, 3, SYSDATE); INSERT INTO item VALUES ( item_s1.nextval ,'ASIN: B000MK4G1M' ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_type = 'XBOX') ,'Pirates of the Caribbean' ,'At Worlds End' , empty_clob() , NULL ,'T' ,'ESRB' ,'22-MAY-2007' , 3, SYSDATE, 3, SYSDATE); -- ------------------------------------------------------------------
  • 175. -- Inserts 5 rentals with 9 dependent rental items. This section inserts -- 5 rows in the RENTAL table, then 9 rows in the RENTAL_ITEM table. The -- inserts into the RENTAL_ITEM tables use scalar subqueries to find the -- proper foreign key values by querying the RENTAL table primary keys. -- ------------------------------------------------------------------ -- Insert 5 records in the RENTAL table. -- ------------------------------------------------------------------ SELECT 'INSERT RENTAL' AS "Section Header" FROM dual; INSERT INTO rental VALUES ( rental_s1.nextval ,(SELECT contact_id FROM contact WHERE last_name = 'Vizquel' AND first_name = 'Oscar') , SYSDATE, SYSDATE + 5
  • 176. , 3, SYSDATE, 3, SYSDATE); INSERT INTO rental VALUES ( rental_s1.nextval ,(SELECT contact_id FROM contact WHERE last_name = 'Vizquel' AND first_name = 'Doreen') , SYSDATE, SYSDATE + 5 , 3, SYSDATE, 3, SYSDATE); INSERT INTO rental VALUES ( rental_s1.nextval ,(SELECT contact_id FROM contact WHERE last_name = 'Sweeney' AND first_name = 'Meaghan') , SYSDATE, SYSDATE + 5
  • 177. , 3, SYSDATE, 3, SYSDATE); INSERT INTO rental VALUES ( rental_s1.nextval ,(SELECT contact_id FROM contact WHERE last_name = 'Sweeney' AND first_name = 'Ian') , SYSDATE, SYSDATE + 5 , 3, SYSDATE, 3, SYSDATE); INSERT INTO rental VALUES ( rental_s1.nextval ,(SELECT contact_id FROM contact WHERE last_name = 'Winn' AND first_name = 'Brian') , SYSDATE, SYSDATE + 5
  • 178. , 3, SYSDATE, 3, SYSDATE); /* -- ------------------------------------------------------------------ -- Insert 9 records in the RENTAL_ITEM table. -- ------------------------------------------------------------------ */ SELECT 'INSERT RENTAL_ITEM' AS "Section Header" FROM dual; INSERT INTO rental_item ( rental_item_id , rental_id , item_id , rental_item_price , rental_item_type , created_by , creation_date , last_updated_by
  • 179. , last_update_date) VALUES ( rental_item_s1.nextval ,(SELECT r.rental_id FROM rental r , contact c WHERE r.customer_id = c.contact_id AND c.last_name = 'Vizquel' AND c.first_name = 'Oscar') ,(SELECT i.item_id FROM item i , common_lookup cl WHERE i.item_title = 'Star Wars - Episode I' AND i.item_subtitle = 'The Phantom Menace' AND i.item_type = cl.common_lookup_id AND cl.common_lookup_type = 'DVD_WIDE_SCREEN') , 5 ,(SELECT common_lookup_id
  • 180. FROM common_lookup WHERE common_lookup_table = 'RENTAL_ITEM' AND common_lookup_column = 'RENTAL_ITEM_TYPE' AND common_lookup_type = '5-DAY RENTAL') , 3, SYSDATE, 3, SYSDATE); INSERT INTO rental_item ( rental_item_id , rental_id , item_id , rental_item_price , rental_item_type , created_by , creation_date , last_updated_by , last_update_date) VALUES ( rental_item_s1.nextval
  • 181. ,(SELECT r.rental_id FROM rental r inner join contact c ON r.customer_id = c.contact_id WHERE c.last_name = 'Vizquel' AND c.first_name = 'Oscar') ,(SELECT d.item_id FROM item d join common_lookup cl ON d.item_title = 'Star Wars - Episode II' WHERE d.item_subtitle = 'Attack of the Clones' AND d.item_type = cl.common_lookup_id AND cl.common_lookup_type = 'DVD_WIDE_SCREEN') , 5 ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'RENTAL_ITEM' AND common_lookup_column = 'RENTAL_ITEM_TYPE' AND common_lookup_type = '5-DAY RENTAL') , 3, SYSDATE, 3, SYSDATE);
  • 182. INSERT INTO rental_item ( rental_item_id , rental_id , item_id , rental_item_price , rental_item_type , created_by , creation_date , last_updated_by , last_update_date) VALUES ( rental_item_s1.nextval ,(SELECT r.rental_id FROM rental r , contact c WHERE r.customer_id = c.contact_id AND c.last_name = 'Vizquel'
  • 183. AND c.first_name = 'Oscar') ,(SELECT d.item_id FROM item d , common_lookup cl WHERE d.item_title = 'Star Wars - Episode III' AND d.item_subtitle = 'Revenge of the Sith' AND d.item_type = cl.common_lookup_id AND cl.common_lookup_type = 'DVD_WIDE_SCREEN') , 5 ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'RENTAL_ITEM' AND common_lookup_column = 'RENTAL_ITEM_TYPE' AND common_lookup_type = '5-DAY RENTAL') , 3, SYSDATE, 3, SYSDATE); INSERT INTO rental_item ( rental_item_id
  • 184. , rental_id , item_id , rental_item_price , rental_item_type , created_by , creation_date , last_updated_by , last_update_date) VALUES ( rental_item_s1.nextval ,(SELECT r.rental_id FROM rental r , contact c WHERE r.customer_id = c.contact_id AND c.last_name = 'Vizquel' AND c.first_name = 'Doreen') ,(SELECT d.item_id FROM item d
  • 185. , common_lookup cl WHERE d.item_title = 'Tomorrow Never Dies' AND d.item_subtitle IS NULL AND d.item_type = cl.common_lookup_id AND cl.common_lookup_type = 'DVD_WIDE_SCREEN') , 5 ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'RENTAL_ITEM' AND common_lookup_column = 'RENTAL_ITEM_TYPE' AND common_lookup_type = '5-DAY RENTAL') , 3, SYSDATE, 3, SYSDATE); INSERT INTO rental_item ( rental_item_id , rental_id , item_id , rental_item_price
  • 186. , rental_item_type , created_by , creation_date , last_updated_by , last_update_date) VALUES ( rental_item_s1.nextval ,(SELECT r.rental_id FROM rental r , contact c WHERE r.customer_id = c.contact_id AND c.last_name = 'Vizquel' AND c.first_name = 'Doreen') ,(SELECT d.item_id FROM item d , common_lookup cl WHERE d.item_title = 'Around the World in 80 Days' AND d.item_subtitle IS NULL
  • 187. AND d.item_type = cl.common_lookup_id AND cl.common_lookup_type = 'DVD_WIDE_SCREEN') , 5 ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'RENTAL_ITEM' AND common_lookup_column = 'RENTAL_ITEM_TYPE' AND common_lookup_type = '5-DAY RENTAL') , 3, SYSDATE, 3, SYSDATE); INSERT INTO rental_item ( rental_item_id , rental_id , item_id , rental_item_price , rental_item_type , created_by , creation_date
  • 188. , last_updated_by , last_update_date) VALUES ( rental_item_s1.nextval ,(SELECT r.rental_id FROM rental r , contact c WHERE r.customer_id = c.contact_id AND c.last_name = 'Sweeney' AND c.first_name = 'Meaghan') ,(SELECT d.item_id FROM item d , common_lookup cl WHERE d.item_title = 'The Patriot' AND d.item_subtitle = 'Special Edition' AND d.item_type = cl.common_lookup_id AND cl.common_lookup_type = 'DVD_WIDE_SCREEN') , 5
  • 189. ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'RENTAL_ITEM' AND common_lookup_column = 'RENTAL_ITEM_TYPE' AND common_lookup_type = '5-DAY RENTAL') , 3, SYSDATE, 3, SYSDATE); INSERT INTO rental_item ( rental_item_id , rental_id , item_id , rental_item_price , rental_item_type , created_by , creation_date , last_updated_by , last_update_date) VALUES
  • 190. ( rental_item_s1.nextval ,(SELECT r.rental_id FROM rental r , contact c WHERE r.customer_id = c.contact_id AND c.last_name = 'Sweeney' AND c.first_name = 'Ian') ,(SELECT d.item_id FROM item d , common_lookup cl WHERE d.item_title = 'Spider-Man' AND d.item_subtitle = 'Fullscreen Special Edition' AND d.item_type = cl.common_lookup_id AND cl.common_lookup_type = 'DVD_FULL_SCREEN') , 5 ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'RENTAL_ITEM'
  • 191. AND common_lookup_column = 'RENTAL_ITEM_TYPE' AND common_lookup_type = '5-DAY RENTAL') , 3, SYSDATE, 3, SYSDATE); INSERT INTO rental_item ( rental_item_id , rental_id , item_id , rental_item_price , rental_item_type , created_by , creation_date , last_updated_by , last_update_date) VALUES ( rental_item_s1.nextval ,(SELECT r.rental_id FROM rental r
  • 192. , contact c WHERE r.customer_id = c.contact_id AND c.last_name = 'Winn' AND c.first_name = 'Brian') ,(SELECT d.item_id FROM item d , common_lookup cl WHERE d.item_title = 'We Were Soldiers' AND d.item_subtitle IS NULL AND d.item_type = cl.common_lookup_id AND cl.common_lookup_type = 'DVD_WIDE_SCREEN') , 5 ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'RENTAL_ITEM' AND common_lookup_column = 'RENTAL_ITEM_TYPE' AND common_lookup_type = '5-DAY RENTAL') , 3, SYSDATE, 3, SYSDATE);
  • 193. INSERT INTO rental_item ( rental_item_id , rental_id , item_id , rental_item_price , rental_item_type , created_by , creation_date , last_updated_by , last_update_date) VALUES ( rental_item_s1.nextval ,(SELECT r.rental_id FROM rental r , contact c WHERE r.customer_id = c.contact_id AND c.last_name = 'Winn'
  • 194. AND c.first_name = 'Brian') ,(SELECT d.item_id FROM item d , common_lookup cl WHERE d.item_title = 'The Hunt for Red October' AND d.item_subtitle = 'Special Collector''s Edition' AND d.item_type = cl.common_lookup_id AND cl.common_lookup_type = 'DVD_WIDE_SCREEN') , 5 ,(SELECT common_lookup_id FROM common_lookup WHERE common_lookup_table = 'RENTAL_ITEM' AND common_lookup_column = 'RENTAL_ITEM_TYPE' AND common_lookup_type = '5-DAY RENTAL') , 3, SYSDATE, 3, SYSDATE); -- Write all prior to program units. COMMIT;
  • 195. -- ---------------------------------------------- -- Create update_price_function. -- ---------------------------------------------- SELECT 'CREATE PRICE UPDATE FUNCTION' AS "Section Header" FROM dual; @@update_price_function.sql SET SERVEROUTPUT ON SIZE UNLIMITED DECLARE lv_count INTEGER; BEGIN IF update_price = 0 THEN SELECT COUNT(*) INTO lv_count FROM price; dbms_output.put_line('Inserted Prices ['||lv_count||'] records.'); ELSE dbms_output.put_line('No Prices Inserted.');
  • 196. END IF; END; / BEGIN FOR i IN (SELECT product FROM product_component_version WHERE REGEXP_LIKE(product,'.+11g.+')) LOOP dbms_output.put_line('Valid ['||i.product||'].'); END LOOP; END; / -- This creates a transactionally safe individual member insert -- into the MEMBER, CONTACT, ADDRESS, STREET_ADDRESS, and -- TELEPHONE tables for Oracle 11g; it won't run in Oracle 10g -- and you should use the contact_insert_10g.sql script in the
  • 197. -- create_store.sql when working on Oracle 10g XE. @@contact_insert.sql @@contact_insert_10g.sql -- Insert complete contact information using stored procedure. -- If you're running on Oracle 10g XE, switch contact_insert to contact_insert_10g as -- a procedure call in the following statements. EXECUTE contact_insert('INDIVIDUAL','R11-514-34','1111- 1111-1111- 1111','VISA_CARD','Clinton','Goeffrey','Ward','CUSTOMER',' HOME','Provo','Utah','84606','118 South 9th East','HOME','011','801','423-1234'); EXECUTE contact_insert('INDIVIDUAL','R11-514-35','1111- 1111-1111- 1111','VISA_CARD','Brandt','Henry','Ward','CUSTOMER','HO ME','Provo','Utah','84606','118 South 9th East','HOME','011','801','423-1234'); EXECUTE contact_insert('INDIVIDUAL','R11-514-36','1111- 2222-1111- 1111','VISA_CARD','Wendy','Jane','Moss','CUSTOMER','HOM E','Provo','Utah','84606','1218 South 10th East','HOME','011','801','423-1234'); EXECUTE contact_insert('INDIVIDUAL','R11-514-37','1111- 1111-2222- 1111','VISA_CARD','Jonah','Simon','Gretelz','CUSTOMER','HO
  • 198. ME','Provo','Utah','84606','2118 South 7th East','HOME','011','801','423-1234'); EXECUTE contact_insert('INDIVIDUAL','R11-514-38','1111- 1111-1111- 2222','MASTER_CARD','Jane','Elizabeth','Royal','CUSTOMER', 'HOME','Provo','Utah','84606','2228 South 14th East','HOME','011','801','423-1234'); EXECUTE contact_insert_10g('INDIVIDUAL','R11-514- 39','1111-1111-3333- 1111','VISA_CARD','Brian','Nathan','Smith','CUSTOMER','HO ME','Spanish Fork','Utah','84606','333 North 2nd East','HOME','011','801','423-1234'); -- Place Chapter 6 Procedure in database. @@transaction_procedure.sql -- Update the address table. UPDATE address SET state_province = 'California' WHERE state_province = 'CA'; -- Conditionally drop table. BEGIN
  • 199. FOR i IN (SELECT table_name FROM user_tables WHERE table_name = 'AIRPORT') LOOP EXECUTE IMMEDIATE 'DROP TABLE '||i.table_name||' CASCADE CONSTRAINTS'; END LOOP; FOR i IN (SELECT sequence_name FROM user_sequences WHERE sequence_name = 'AIRPORT_S1') LOOP EXECUTE IMMEDIATE 'DROP SEQUENCE '||i.sequence_name; END LOOP; END; / -- Create table. CREATE TABLE airport ( airport_id NUMBER CONSTRAINT pk_airport PRIMARY KEY
  • 200. , airport_code VARCHAR2(3) CONSTRAINT nn_airport1 NOT NULL , airport_city VARCHAR2(30) CONSTRAINT nn_airport2 NOT NULL , city VARCHAR2(30) CONSTRAINT nn_airport3 NOT NULL , state_province VARCHAR2(30) CONSTRAINT nn_airport4 NOT NULL , created_by NUMBER , creation_date DATE , last_updated_by NUMBER , last_update_date DATE , CONSTRAINT fk_airport1 FOREIGN KEY (created_by) REFERENCES system_user (system_user_id) , CONSTRAINT fk_airport2 FOREIGN KEY (last_updated_by) REFERENCES system_user (system_user_id)); -- Create sequence. CREATE SEQUENCE airport_s1;