Documente Academic
Documente Profesional
Documente Cultură
Amazing Books
Introduction
SCENARIO
Cicely Williams inherited her uncle's bookstore after he retired in 2001. In the
last several years, the bookstore's sales have skyrocketed. Cicley can no longer
continue to manage the business without using a database to store customer
records, track inventory and access accounting information. Eventually, Cicely
would like to take the business online, but first she needs an easier way to
manage the details of her business in house.
• search her inventory for book titles, authors, ISBN numbers, book editions,
book subjects and publishers.
• track sales for other merchandise items and display wholesale and retail
prices for all items
• insert, update and delete items from her items inventory
• track customer information for emailing store specials, new books, book
signings, etc.
• place and view customer orders
INSTRUCTIONS
The Amazing Books Project uses Oracle Application Express SQL Workshop
and the Application Builder tools to build a database for the Amazing Books
bookstore. The project is divided into seven parts. Each part consists of several
steps. Each step has detailed instructions and supporting graphics.
Part 2: Creating the application's pages, page style and Popup List of Values
(LOVs).
Part 3: Creating the input forms and report regions for the application's
CUSTOMERS, SUBJECTS, PUBLISHERS, ITEM_TYPES pages.
Part 5: Creating the input forms and report areas for the application’s ORDERS
and ITEMS pages to enable use of the LOVs for inputting data.
Let's begin....
Be sure to have a copy of the entity relationship diagram (ERD) and schema
diagrams available as you go through this section. You will need to reference
them as you build the tables.
In the Login screen, enter your Workspace, Username, and Password. Click
Login.
2.2 Use the Object Browser to create the tables for the project.
A. Click the drop-down menu for Object Browser. Select Create-> Table.
CUSTOMERS CUSTOMERS
pk customer_id # customer_id
customer_name * customer_name
address * address
city * city
state_province o
state_province
country *country
email o
email
B. Create the fields in the table by entering the data in the picture into the
Column Name, Type, Precision and Scale textboxes.
C. According to the ERD, some columns are optional and others are
required. Check Not Null for the columns that must not have a null value
(a NOT NULL constraint will be created when the table is created).
Note: Primary Keys will set to NOT NULL by default, but in this case, we
are checking the value anyway.
A. The primary key values for the CUSTOMERS table will be generated from
a sequence. Choose “Populated from a new sequence” for the Primary
Key.
3.4 Skip the step of creating a foreign key for the CUSTOMERS table.
The next part of creating a table in Application Express is defining the foreign
key. Since CUSTOMERS is the first table in this project, there are no foreign
keys to reference yet. We will create all the "connections" or foriegn keys after
we have created all the tables. Click Next to continue.
3.5 Skip the step of creating additional constraints for the CUSTOMERS
table.
The next step in the table creation process is to create constraints for the table.
There are no constraints needed for the CUSTOMERS table. Click Finish.
Note that you can review the SQL code that will be used to create the table by
expanding the SQL section.
ORDERS
pk order_id ORDERS
fk customer_id # order_id
order_date * order_date
quantity * quantity
fk item_id
4.5 Skip the step for creating a constraint for the ORDERS table.
There are no other constraints for this table. Click Finish.
4.6 Confirm the create table request.
The final step in the create table process is to confirm your request to create the
ORDERS table. In the Create Table window, click Create.
Note that you can review the SQL code that will be used to create the table by
expanding the SQL section.
ITEMS ITEMS
pk item_id # item_id
isbn * isbn
title * title
author * author
fk publisher_id * wholesale_cost
fk subject_id * retail_price
fk item_type_id
wholesale_cost
retail_price
SUBJECTS SUBJECTS
pk subject_id # subject_id
subject * subject
PUBLISHERS PUBLISHER
pk publisher_id #publisher_id
publisher *publisher
ITEM_TYPES ITEM_TYPES
pk item_type_id # item_type_id
item_type * item_type
9.2 Create the foreign key for the ORDERS table to CUSTOMERS
A. In Object Browser, select Browse -> Tables.
B. Click to SELECT the ORDERS table from the list of tables displayed.
C. Click on the CONSTRAINTS tab to begin creating the foriegn key between
the ORDERS table and the CUSTOMERS table.
D. Click on the CREATE button to create a new foriegn key constraint for the
ORDERS table.
F. Populate the fields with the following values and then click NEXT to continue.
H. Confirm the foriegn key is now created in the ORDERS table referencing the
CUSTOMER table using the CUSTOMER table's primary key.
9.3 Create the foreign key for the ORDERS table to ITEMS.
B. Click to SELECT the ORDERS table from the list of tables displayed.
C. Click on the CONSTRAINTS tab to begin creating the foriegn key between
the ORDERS table and the CUSTOMERS table.
D. Click on the CREATE button to create a new foriegn key constraint for the
ORDERS table.
F. Populate the fields with the following values and then click NEXT to continue.
H. Confirm the foriegn key is now created in the ORDERS table referencing the
ITEMS table using the ITEMS table primary key.
9.4 Create the foreign keys for the ITEMS table to the SUBJECTS,
PUBLISHERS and ITEM_TYPES tables.
A. In Object Browser, select Browse -> Tables.
B. Click to SELECT the ORDERS table from the list of tables displayed.
C. Click on the CONSTRAINTS tab to begin creating the foriegn key between
the ORDERS table and the CUSTOMERS table.
D. Click on the CREATE button to create a new foriegn key constraint for the
ITEMS table.
F. Create the following 3 foriegn keys by populating the fields with the following
values. Click NEXT to continue creating the foriegn keys until completed.
These are the values to create the foriegn key for the ITEMS table to the
ITEMS_TYPES table.
These are the values to create the foriegn key for the ITEMS table to the
PUBLISHER table.
These are the values to create the foriegn key for the ITEMS table to the
SUBJECTS table.
Summary
In Step 9, you created five foriegn keys. Two foriegn keys in the ORDERS table
which created a connection to CUSTOMERS and ITEMS. We created three
foriegn keys in the ITEMS table creating a connection between the ITEMS table
and SUBJECTS, PUBLISHERS, and ITEM_TYPES respectively.
These tables are the foundation for building any application. In Part 2, we will
create an application which will use the tables you just created. We'll continue to
add functionality to this application throughout this project.
Let's continue...