Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[10 marks] Provide the correct SQL statements for the following three questions using the ERD schema shown below. Part A. Write a SQL statement to

image text in transcribed
image text in transcribed
[10 marks] Provide the correct SQL statements for the following three questions using the ERD schema shown below. Part A. Write a SQL statement to show customer names and addresses for customers who have placed orders in 2022 (i.e. placed orders this year). Customers should show up only once if they have orders in 2022. (4 marks) Part B. Write the SQL to add a new table called "Recalls" that has four columns ( r id, r code, r_text, p_id). rid is the primary key and should be created so that it's value is created automatically by the database server. p id refers to the primary key in the Products table and should be treated as a foreign key. Decide for yourself what the proper data types are for all the columns. (2 marks) Part C. Write a SQL statement to show product sales activity. Display the p_name and total sales for that product, ordered from the product with the most sales to the least sales. Include products that have zero sales. NOTE: Product names are not unique. (4 marks) \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ Products } \\ \hline p_id \\ p_name \\ p_price \\ p_description \end{tabular} \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ Orders } \\ \hline o_id \\ o_date \\ c_id \\ \hline \end{tabular} \begin{tabular}{|l|} \hline Order_Details \\ \hline od_id \\ od_quantity \\ o_id \\ p_id \end{tabular}\begin{tabular}{l} Customers \\ \hline c_id \\ \hline c_name \\ c_address \\ \hline \end{tabular}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions

Question

Explain why we forget.

Answered: 1 week ago

Question

What is American Polity and Governance ?

Answered: 1 week ago