Chapter Three – Structured Query Language
ANSWERS TO THE QUEEN ANNE CURIOSITY SHOP PROJECT QUESTIONS
Assume that The Queen Anne Curiosity Shop designs a database with the following
tables.
CUSTOMER (CustomerID, LastName, FirstName, Address, City, State, ZIP, Phone,
EmailAddress)
The referential integrity constraints are:
VendorID in ITEM must exist in VendorID in VENDOR
CustomerID in SALE must exist in CustomerID in CUSTOMER
Assume that CustomerID of CUSTOMER, EmployeeID of EMPLOYEE, VendorID of
VENDOR, ItemID of ITEM, and SaleID of SALE are all surrogate keys with values as
follows:
CustomerID Start at 1 Increment by 1
EmployeeID Start at 1 Increment by 1
VendorID Start at 1 Increment by 1
ItemID Start at 1 Increment by 1
SaleID Start at 1 Increment by 1
SaleItemID of SALE_ITEM is not a true surrogate key, but rather a counter that starts at
1 and increments by 1 for each SaleID in SALE. This number will require special
handling in the database, needing to be either manually inserted or to have specific
program logic written to insert the correct number. In this text we will simply insert the
number manually.
A vendor may be an individual or a company. If the vendor is an individual, the
CompanyName field is left blank, while the ContactLastName and ContactFirstName
fields must have data values. If the vendor is a company, the company name is
recorded in the CompanyName field, and the name of the primary contact at the
company is recorded in the ContactLastName and ContactFirstName fields.
Some sample data are shown in Figures 3-44, 3-45, 3-46, 3-47, 3-48, and 3-49. These
tables, referential integrity constraints, and data are used as the basis for the SQL
statements you will create in the exercises that follow. If possible, run these statements
in an actual DBMS, as appropriate, to obtain your results. Name your database QACS.