Question: SQL Problem: Create a new table named Customers_Statistics with the following columns: Customer_id, Customer_Last_Name, Number_of_Orders, Number_of_Items Complete the table definition by choosing the appropriate data

SQL Problem:

Create a new table named Customers_Statistics with the following columns: Customer_id, Customer_Last_Name, Number_of_Orders, Number_of_Items Complete the table definition by choosing the appropriate data types, primary and foreign keys.

1. Now lets update the table so that Customer_Status(its a column with max string of 5) has the following values: ok when the number of orders is 0 or 1 good when the number of orders is 2 or more great when the number of orders is > 5 and the number of items is >5

2. Delete from the table Customers_Statistics all the customers that have not placed any orders

3. Modify the table and change the column definition of Number_of_Items to a column that cannot be NULL

4. Modify the table and change the column definition of Number_of_Orders to a column that has a default value 0

5. Update the records of table Customer_Statistics and set the last names of all customers with id larger than 20 to Keenan.

6. Drop the foreign key constraint you created earlier (the one that says that Customer_Id of Customer_Statistics references Customer_Id of Customers). If you did not create the FK create it first and then drop it.

7. Insert a new record with Customer_Id = 100, Customer_Last_Name= Polychronopoulou (or anything else!) and 0 for orders and items. Dont forget to commit! Extra: Could you have done that without dropping the FK?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!