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) Write a merge statement to merge the data of the tables Customers and Customer_Statistics. You should modify the data of table Customer_Statistics by: Compare the records using customer_id If the ids are the same but the last names are different then update table Customer Statistics to match Customers If the ids exist In Customers and not exist in Customer_Statistics then insert the customer with 0 values for items and orders.

2) A. Create a view that holds only the customers that have a Customer_Status ok. B. Now update one of the customers names using the view. Do you see this change transferred to Customers table?

3) Now create a view that holds the customers that have a Customer_Status ok and are from California, using the WITH CHECK option. Now update again one of the customers names using the view. Do you see this change transferred to Customers table? Now update the state, can you do that?

4) Truncate table Customers_Statistics. Can you still see the table definition? What about the data?

5) Drop table Customers_Statistics. Can you still see the table definition?

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!