Assignment 3
Assignment 3
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
1
2
3
4
Huntington
Tadema
Lee
Smith
Anne
Ken
Andrew
Mark
Seattle
Seattle
Kirkland
Seattle
[email protected]
[email protected]
[email protected]
[email protected]
ITEM Table:
ItemID
1
2
3
4
5
6
ItemDescription
Antique Desk
Antique Desk Chair
Dining Table Linens
Candles
Antique Chair
Antique Chair
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