Uploaded by Mutshidzi Magoro

ASSIGNMNET 1 2021 (4)

advertisement
ASSIGNMENT 1
Perfect Pizza is a pizza delivery shop. They make pizzas only for home delivery. They have recently
designed a new database to track their sales. They use the customer’s telephone number for a Key
column in the Customer table. They are interested in households, not individuals. They need the street
address and zip code for the delivery. They deliver to only three zip codes 98001, 98002, and 98003.
With the zip code, they can fill in city and state information later, though they prefer to do it when
they enter a new customer. In the OrderDetail table, they store the price charged for two reasons:
First, it may be different than product price due to a discount or special allowance and second, it keeps
a historic record of the price. That way, if they change the price in the Product table, it doesn’t affect
the prices charged in past sales. Here is the entity relation diagram for the database.
Pizza ERD
1
2
PART A
1. What do you think would be the appropriate data types for CustomerPhoneKey and
CustomerZip? Explain.
2. What do you think would be the appropriate data types for ProductUnitSize and
ProductUnitPrice? Explain.
3. Create the database in Ms SQL Server/Oracle Express/MySQL and build the database tables
depicted in the entity relation diagram in, choosing appropriate data types. (Use the sample
data as a guide.) (Take screen shots and attach)
4. Create a database diagram and use it to create the relationships among the tables. (Take
screen shots and attach)
5. Add these sample records to the appropriate tables. (Take screen shots and attach)
PART B
Use the Pizza database you created and write SQL to answer these questions:
1. List all last names, phone numbers, and zip of the customers.
2. List only those from Zip code 98002.
3. List all the customers that have no first address entered in the database.
4. List all the products that are priced higher than $10.
5. List all the products priced between $5 and $7.
6. List all the customers whose last name starts with L.
7. What is the average price of a product?
8. What is the highest price of a product?
9. What is the total due for order 1003?
10. Join the product and the OrderDetail table so that the result contains the product name,
product unit size, and product unit price as well the charged price. Do it for order 1000.
11. List all the order and order details for each order made by the customer with the phone
number 2065556623.
12. Change the price of breadsticks to 3.00.
13. Process a pizza order for a new customer (this will involve 3 INSERT statements).
3
Download