0% found this document useful (0 votes)
397 views

Assignment 3

The document describes a database for a curiosity shop with tables for customers, vendors, items, and sales. It provides the structure of the tables with attributes and foreign key relationships. It also provides sample data to insert into each table. The task is to write SQL statements to: A) Create the tables with attributes, data types, primary keys and foreign key constraints. B) Insert the provided sample data into each table.

Uploaded by

Arshsadana
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
397 views

Assignment 3

The document describes a database for a curiosity shop with tables for customers, vendors, items, and sales. It provides the structure of the tables with attributes and foreign key relationships. It also provides sample data to insert into each table. The task is to write SQL statements to: A) Create the tables with attributes, data types, primary keys and foreign key constraints. B) Insert the provided sample data into each table.

Uploaded by

Arshsadana
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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

[email protected]
[email protected]
[email protected]
[email protected]

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