Assignment 3

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

THE QUEEN ANNE CURIOSITY SHOP PROJECT QUESTIONS (PART 1)

Submission: A SINGLE SQL file (not word or pdf!) to Dropbox on ANGEL


Assume that The Queen Anne Curiosity Shop designs a database with the following
tables.
CUSTOMER (CustomerID, LastName, FirstName, City, Phone)
VENDOR (VendorID, CompanyName, ContactLastName, ContactFirstName, City, Email)
ITEM (ItemID, ItemDescription, PurchaseDate, ItemCost, VendorID)
SALE (SaleID, CustomerID, ItemID, SaleDate, SubTotal, Tax, Total)

The referential integrity constraints are:


VendorID in ITEM must exist in VendorID in VENDOR
CustomerID in SALE must exist in CustomerID in CUSTOMER
ItemID in SALE must exist in ItemID in ITEM

Assume that CustomerID of CUSTOMER, VendorID in VENDOR, ItemID of ITEM,


SaleID of SALE, are all surrogate keys with values as follows:
CustomerID

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

Write SQL statements and answer questions for this database as follows:
A.

Write SQL CREATE TABLE statements for each of these tables. (30 points)
Hints:
a. Remember to write foreign key constraints for the relationships in each of these
tables. Make your own assumptions regarding cascading deletions/updates.
b. See data samples in Question B to determine whether an attribute should be
NULL or NOT NULL.
c. For data types, refer to our sample SQL in slides.

B.

Write SQL statements to insert following data to each table. Make sure you insert
the complete and exactly the same data as shown in the following tables. (10
points)

CUSTOMER Table:
CustomerID
1
2
3

LastName
Shire
Goodyear
Bancroft

FirstName
Robert
Katherine
Chris

City
Seattle
Seattle
Bellevue

Phone
206-524-2433
206-524-3544
425-635-9788

VENDOR Table:
VendorID

CompanyName

ContactLastName

ContactFirstName

City

Email

1
2
3
4

Linens and Things


European Specialties

Huntington
Tadema
Lee
Smith

Anne
Ken
Andrew
Mark

Seattle
Seattle
Kirkland
Seattle

LAT@business.com
ES@business.com
Andrew.Lee@somewhere.com
NYB@business.com

New York Brokerage

ITEM Table:
ItemID
1
2
3
4
5
6

ItemDescription
Antique Desk
Antique Desk Chair
Dining Table Linens
Candles
Antique Chair
Antique Chair

PruchaseDate ItemCost VendorID


7-Nov-12
1800
2
28-Nov-12
300
3
14-Nov-12
600
1
14-Nov-12
30
1
28-Nov-12
750
4
28-Nov-12
1050
4

SALE Table:
SaleID
1
2
3
4

CustomerID
1
2
3
2

ItemID
2
3
1
4

SaleDate
14-Dec-12
15-Dec-12
15-Dec-12
15-Jan-13

SubTotal
3500
1000
50
3000

Tax
290.5
83
4.15
249

Total
3790.5
1083
54.15
3249

You might also like