Identify all queries that meet the stated specifications. 2. For each query that does not meet...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Identify all queries that meet the stated specifications. 2. For each query that does not meet the stated specifications briefly state exactly what is wrong with the query. If there is an error briefly explain what the error is. If it does not provide the required results briefly explain why Question#1(40 points) Which of the following queries display the total number of customer records that are being selected by the query? (Choose all that apply-if any. Give a brief but detailed explanation of what is wrong with each query you did not each select.) a) SELECT COUNT(*, SUM (balance) FROM customer INNER JOIN rep ON rep.rep_num= customer.customer_num; b) SELECT COUNT(*), SUM (balance) FROM rep INNER JOIN customer ON rep.rep_num= customer.rep_num; c) SELECT COUNT (DISTINCT customer.rep_num), SUM (balance) FROM customer RIGHT JOIN rep ON rep.rep_num= customer.rep_num; d) SELECT COUNT(rep.rep num), SUM (balance) FRUM rep LEFT JOIN customer ON rep.rep_num= customer.rep_num; e) SELECT COUNT(customer.rep_num), SUM (balance) FROM rep LEFT JOIN customer ON rep.rep_num= customer.rep_num; Enter your answer here: Question#2(40 points) Which of the following queries displays the customer name and customer number for customers that have a balance greater than the average balance for all customers and live in a city where no sales representatives live? (Choose all that apply -if any. Give a brief but detailed explanation of what is wrong with each query you did not each select.) a) SELECT customer_name, customer_num FROM customer WHERE customer.city (SELECT city FROM rep) AND customer.balance > (SELECT AVG (customer. balance) FROM customer); b) SELECT premiere.customer.customer_name, premiere.customer.customer_num FROM customer WHERE customer.city NOT IN (SELECT city FROM rep) AND customer.balance < (SELECT AVG (customer.balance) FROM customer); c) SELECT customer_name, premiere. customer.customer_num FROM customer WHERE customer.city NOT IN (SELECT city FROM rep) AND customer.balance > (SELECT SUM (customer.balance) /COUNT(*) FROM customer); d) SELECT customer.rep_num, customer.customer_name FROM customer WHERE customer.city NOT IN (SELECT city FROM rep) AND customer.balance > (SELECT AVG (customer.balance) FROM customer); e) SELECT customer.rep_num, customer.customer_name FROM customer WHERE customer.city NOT IN (SELECT city FROM rep) AND customer.balance < (SELECT AVG (customer.balance) FROM customer); Enter your answer here: Question#3 (40 points) Which of the following queries show the representative name and representative number of all representatives who are currently earning a rate equal to the minimum rate for all representatives and share a first initial with the customer that they represent? (Choose all that apply -if any. Give a brief but detailed explanation of what is wrong with each query you did not each select.) a) SELECT first_name, last_name, rep.rep_num FROM rep INNER JOIN customer ON rep.rep_num = customer.rep_num WHERE rate= (SELECT MIN (rate) FROM rep) AND LEFT (first_name, 1) = LEFT (customer_name, 1); b) SELECT first_name, last_name, rep.rep_num FROM rep WHERE rate = (SELECT MIN (rate) FROM rep) AND rep_num IN (SELECT c.rep_num FROM customer C, rep R. WHERE C.rep_num= R.Rep_num AND LEFT (C.customer_name, 1) LEFT (R.first_name, 1)); c) SELECT rep.rep_num, rep.first_name, rep.last_name FROM rep LEFT JOIN rep ON rep.rep_num= rep.rep_num WHERE rate = MIN (rate) AND first name LIKE customer_name; d) SELECT rep.rep_num, first_name, last_name FROM rep, customer WHERE rep.rep _num= customer.rep_num AND rate= (SELECT MIN (rate) FROM rep) AND LEFT (first_name, 1) = LEFT (customer_name, 1); e) SELECT rep.rep_num, first_name, last_name FROM rep, customer WHERE rep.rep_num= customer.customer_num AND rate = (SELECT MIN (rate) FROM rep) AND LEFT (first_name, 1) = LEFT (customer_name, 1); Enter your answer here: = Question#4 (40 points) Which query would show which customers have purchased a Home Gym and live in the same city as a sales representative? (Choose all that apply -if any. Give a brief but detailed explanation of what is wrong with each query you did not each select.) a) SELECT customer.customer num, customer name. FROM customer INNER JOIN rep ON customer.rep_num = rep.rep_num INNER JOIN customer.order_num= orders.order_num INNER JOIN order line ON orders.order num = order line.order num INNER JOIN part ON part.part_num= order_line.part_num WHERE description LIKE 'Home Gym' b) SELECT customer.customer_num, customer_name FROM customer INNER JOIN orders ON customer.customer_num = orders.customer_num INNER JOIN order_line ON orders.order_num = order_line.order_num INNER JOIN part ON part.part_num= order_line.part_num WHERE description LIKE 'Home Gym' AND city IN (SELECT city FROM rep; c) SELECT customer.customer_num, customer_name FROM customer, orders, order_line, part WHERE customer.customer_num = orders.customer_num orders.order_num= order_line.order_num AND AND part.part_num= order_line.part_num AND description LIKE 'Home Gym' AND city IN (SELECT city FROM rep); d) SELECT rep.city, customer.city, part.description FROM rep, customer, part WHERE description = 'Home Gym' AND customer.city = rep.city; e) SELECT customer.customer_num, customer_name FROM customer UNION SELECT rep.city Sua FROM rep UNION ALL SELECT part.description FROM part WHERE description = 'Home Gym'; Enter your answer here: Question# 5 (40 points) Which query would show which sales representatives (that have at least one customer) what the number of orders their customers have made sorting the list from highest number of orders to lowest number of orders? (Choose all that apply -if any. Give a brief but detailed explanation of what is wrong with each query you did not each select.) a) SELECT rep.rep_num, rep.first_name, rep.last_name, COUNT (orders.order num) FROM rep INNER JOIN customer ON rep.rep_num= customer.rep_num INNER JOIN orders ON orders. customer num = customer.customer num GROUP BY rep.rep_num HAVING COUNT (customer.customer_num) >= 1 ORDER BY COUNT (orders.order_num) DESC; b) SELECT rep.rep_num, rep.first_name, rep.last_name, COUNT (orders.order_num) FROM rep, customer, orders WHERE rep.rep_num= customer.rep_num AND orders. customer_num= customer.customer_num GROUP BY rep.rep_num HAVING COUNT (customer.customer_num) >= 1 ORDER BY COUNT (orders.order_num) DESC; c) SELECT rep.rep_num, rep.first_name, rep.last_name, COUNT (orders.order num). FROM rep, customer, orders WHERE rep.rep_num = customer.rep_num AND orders.customer_num = customer.customer_num AND COUNT (customer.customer num). >= 1 GROUP BY rep.rep_num ORDER BY COUNT (orders.order_num) DESC; d) SELECT rep.rep_num, rep. first_name, rep.last_name, COUNT (orders.order_num) FROM rep, customer, orders WHERE rep.rep_num = customer.rep_num AND orders.customer num = customer.customer num AND COUNT (customer.customer_num) > 1 GROUP BY rep.rep_num opp ORDER BY COUNT (orders.order num) DESC; ******* UNION SELECT rep.rep_num, rep.first_name, rep.last_name, COUNT COUNT (orders.order_num) FROM FROM rep, customer, orders ... WHERE rep.rep_num = customer.rep_num AND orders.customer_num= customer.customer_num. AND COUNT (customer.customer_num) = 1 GROUP BY rep.rep_num; e) SELECT rep.rep_num, rep.first_name, rep.last_name, COUNT (orders.order num) FROM rep INNER JOIN customer ON rep.rep_num= customer.rep_num INNER JOIN orders ON orders.order_num= customer.customer_num GROUP BY rep.rep_num HAVING COUNT (customer.customer_num) >= 1 ORDER BY COUNT (orders.order num) DESC; Enter your answer here: Section B (100 points): Additional Topics Question#1 (60 points) You company's online ordering system has a login screen and you detected the following input being entered: OR 0 = 0; DROP DATABASE GatorWareSoftware; a) What is probably being attempted here? b) Explain in detail what each part of the input above is supposed to do -starting with the single quote at the beginning. c) Explain in detail what measures can be used to protect your database against user inputs such as this. Enter your answer here: Question #2 (20 points) Using the testbed database: a) Create a view called LastHireDate for the GatorWare Employee table that displays the date the most recent employee was hired (if necessary recreate the GatorWareEmployee table first using the code provided in the folder on the Azure desktop). Provide both the code listing for the view, the code to run the view, and a screenshot of the view being run. (15 points) b) Explain how views can enhance database security. (5 points) Enter your answer here: Question# 3 (20 points) Using the testbed database: a) Create an index called JobCodeIndex for the GatorWare Employee table that speeds up searches using the jobCode column (if necessary recreate the GatorWareEmployee table first using the code provided in the folder on the Azure desktop). Provide the code for creating the index, and a screenshot of index being created. (10 points) b) What are the advantages and disadvantages of creating additional indexes on a table? (10 points) Enter your answer here: *Please note the due date and the final date for submissions to be accepted! Submissions past these dates will not be accepted and will receive a grade of zero. Identify all queries that meet the stated specifications. 2. For each query that does not meet the stated specifications briefly state exactly what is wrong with the query. If there is an error briefly explain what the error is. If it does not provide the required results briefly explain why Question#1(40 points) Which of the following queries display the total number of customer records that are being selected by the query? (Choose all that apply-if any. Give a brief but detailed explanation of what is wrong with each query you did not each select.) a) SELECT COUNT(*, SUM (balance) FROM customer INNER JOIN rep ON rep.rep_num= customer.customer_num; b) SELECT COUNT(*), SUM (balance) FROM rep INNER JOIN customer ON rep.rep_num= customer.rep_num; c) SELECT COUNT (DISTINCT customer.rep_num), SUM (balance) FROM customer RIGHT JOIN rep ON rep.rep_num= customer.rep_num; d) SELECT COUNT(rep.rep num), SUM (balance) FRUM rep LEFT JOIN customer ON rep.rep_num= customer.rep_num; e) SELECT COUNT(customer.rep_num), SUM (balance) FROM rep LEFT JOIN customer ON rep.rep_num= customer.rep_num; Enter your answer here: Question#2(40 points) Which of the following queries displays the customer name and customer number for customers that have a balance greater than the average balance for all customers and live in a city where no sales representatives live? (Choose all that apply -if any. Give a brief but detailed explanation of what is wrong with each query you did not each select.) a) SELECT customer_name, customer_num FROM customer WHERE customer.city (SELECT city FROM rep) AND customer.balance > (SELECT AVG (customer. balance) FROM customer); b) SELECT premiere.customer.customer_name, premiere.customer.customer_num FROM customer WHERE customer.city NOT IN (SELECT city FROM rep) AND customer.balance < (SELECT AVG (customer.balance) FROM customer); c) SELECT customer_name, premiere. customer.customer_num FROM customer WHERE customer.city NOT IN (SELECT city FROM rep) AND customer.balance > (SELECT SUM (customer.balance) /COUNT(*) FROM customer); d) SELECT customer.rep_num, customer.customer_name FROM customer WHERE customer.city NOT IN (SELECT city FROM rep) AND customer.balance > (SELECT AVG (customer.balance) FROM customer); e) SELECT customer.rep_num, customer.customer_name FROM customer WHERE customer.city NOT IN (SELECT city FROM rep) AND customer.balance < (SELECT AVG (customer.balance) FROM customer); Enter your answer here: Question#3 (40 points) Which of the following queries show the representative name and representative number of all representatives who are currently earning a rate equal to the minimum rate for all representatives and share a first initial with the customer that they represent? (Choose all that apply -if any. Give a brief but detailed explanation of what is wrong with each query you did not each select.) a) SELECT first_name, last_name, rep.rep_num FROM rep INNER JOIN customer ON rep.rep_num = customer.rep_num WHERE rate= (SELECT MIN (rate) FROM rep) AND LEFT (first_name, 1) = LEFT (customer_name, 1); b) SELECT first_name, last_name, rep.rep_num FROM rep WHERE rate = (SELECT MIN (rate) FROM rep) AND rep_num IN (SELECT c.rep_num FROM customer C, rep R. WHERE C.rep_num= R.Rep_num AND LEFT (C.customer_name, 1) LEFT (R.first_name, 1)); c) SELECT rep.rep_num, rep.first_name, rep.last_name FROM rep LEFT JOIN rep ON rep.rep_num= rep.rep_num WHERE rate = MIN (rate) AND first name LIKE customer_name; d) SELECT rep.rep_num, first_name, last_name FROM rep, customer WHERE rep.rep _num= customer.rep_num AND rate= (SELECT MIN (rate) FROM rep) AND LEFT (first_name, 1) = LEFT (customer_name, 1); e) SELECT rep.rep_num, first_name, last_name FROM rep, customer WHERE rep.rep_num= customer.customer_num AND rate = (SELECT MIN (rate) FROM rep) AND LEFT (first_name, 1) = LEFT (customer_name, 1); Enter your answer here: = Question#4 (40 points) Which query would show which customers have purchased a Home Gym and live in the same city as a sales representative? (Choose all that apply -if any. Give a brief but detailed explanation of what is wrong with each query you did not each select.) a) SELECT customer.customer num, customer name. FROM customer INNER JOIN rep ON customer.rep_num = rep.rep_num INNER JOIN customer.order_num= orders.order_num INNER JOIN order line ON orders.order num = order line.order num INNER JOIN part ON part.part_num= order_line.part_num WHERE description LIKE 'Home Gym' b) SELECT customer.customer_num, customer_name FROM customer INNER JOIN orders ON customer.customer_num = orders.customer_num INNER JOIN order_line ON orders.order_num = order_line.order_num INNER JOIN part ON part.part_num= order_line.part_num WHERE description LIKE 'Home Gym' AND city IN (SELECT city FROM rep; c) SELECT customer.customer_num, customer_name FROM customer, orders, order_line, part WHERE customer.customer_num = orders.customer_num orders.order_num= order_line.order_num AND AND part.part_num= order_line.part_num AND description LIKE 'Home Gym' AND city IN (SELECT city FROM rep); d) SELECT rep.city, customer.city, part.description FROM rep, customer, part WHERE description = 'Home Gym' AND customer.city = rep.city; e) SELECT customer.customer_num, customer_name FROM customer UNION SELECT rep.city Sua FROM rep UNION ALL SELECT part.description FROM part WHERE description = 'Home Gym'; Enter your answer here: Question# 5 (40 points) Which query would show which sales representatives (that have at least one customer) what the number of orders their customers have made sorting the list from highest number of orders to lowest number of orders? (Choose all that apply -if any. Give a brief but detailed explanation of what is wrong with each query you did not each select.) a) SELECT rep.rep_num, rep.first_name, rep.last_name, COUNT (orders.order num) FROM rep INNER JOIN customer ON rep.rep_num= customer.rep_num INNER JOIN orders ON orders. customer num = customer.customer num GROUP BY rep.rep_num HAVING COUNT (customer.customer_num) >= 1 ORDER BY COUNT (orders.order_num) DESC; b) SELECT rep.rep_num, rep.first_name, rep.last_name, COUNT (orders.order_num) FROM rep, customer, orders WHERE rep.rep_num= customer.rep_num AND orders. customer_num= customer.customer_num GROUP BY rep.rep_num HAVING COUNT (customer.customer_num) >= 1 ORDER BY COUNT (orders.order_num) DESC; c) SELECT rep.rep_num, rep.first_name, rep.last_name, COUNT (orders.order num). FROM rep, customer, orders WHERE rep.rep_num = customer.rep_num AND orders.customer_num = customer.customer_num AND COUNT (customer.customer num). >= 1 GROUP BY rep.rep_num ORDER BY COUNT (orders.order_num) DESC; d) SELECT rep.rep_num, rep. first_name, rep.last_name, COUNT (orders.order_num) FROM rep, customer, orders WHERE rep.rep_num = customer.rep_num AND orders.customer num = customer.customer num AND COUNT (customer.customer_num) > 1 GROUP BY rep.rep_num opp ORDER BY COUNT (orders.order num) DESC; ******* UNION SELECT rep.rep_num, rep.first_name, rep.last_name, COUNT COUNT (orders.order_num) FROM FROM rep, customer, orders ... WHERE rep.rep_num = customer.rep_num AND orders.customer_num= customer.customer_num. AND COUNT (customer.customer_num) = 1 GROUP BY rep.rep_num; e) SELECT rep.rep_num, rep.first_name, rep.last_name, COUNT (orders.order num) FROM rep INNER JOIN customer ON rep.rep_num= customer.rep_num INNER JOIN orders ON orders.order_num= customer.customer_num GROUP BY rep.rep_num HAVING COUNT (customer.customer_num) >= 1 ORDER BY COUNT (orders.order num) DESC; Enter your answer here: Section B (100 points): Additional Topics Question#1 (60 points) You company's online ordering system has a login screen and you detected the following input being entered: OR 0 = 0; DROP DATABASE GatorWareSoftware; a) What is probably being attempted here? b) Explain in detail what each part of the input above is supposed to do -starting with the single quote at the beginning. c) Explain in detail what measures can be used to protect your database against user inputs such as this. Enter your answer here: Question #2 (20 points) Using the testbed database: a) Create a view called LastHireDate for the GatorWare Employee table that displays the date the most recent employee was hired (if necessary recreate the GatorWareEmployee table first using the code provided in the folder on the Azure desktop). Provide both the code listing for the view, the code to run the view, and a screenshot of the view being run. (15 points) b) Explain how views can enhance database security. (5 points) Enter your answer here: Question# 3 (20 points) Using the testbed database: a) Create an index called JobCodeIndex for the GatorWare Employee table that speeds up searches using the jobCode column (if necessary recreate the GatorWareEmployee table first using the code provided in the folder on the Azure desktop). Provide the code for creating the index, and a screenshot of index being created. (10 points) b) What are the advantages and disadvantages of creating additional indexes on a table? (10 points) Enter your answer here: *Please note the due date and the final date for submissions to be accepted! Submissions past these dates will not be accepted and will receive a grade of zero.
Expert Answer:
Related Book For
Concepts of Database Management
ISBN: 978-1285427102
8th edition
Authors: Philip J. Pratt, Mary Z. Last
Posted Date:
Students also viewed these databases questions
-
For the given reaction the formation of products I and II follows, which of the following mechanism: N CHO II hy CHO CHO I: Con rotatory thermal eight electron electrocyclic reaction. It: Dis...
-
ACC 122 I. On July 1st, Gillian Gardener began Gillian's Gardening Services (GGS) and had the following transactions: 7-1: Gillian Gardener contributed $200,000 in cash to GGS. 7-1: GGS signed a...
-
Complete the following assignment below: Shirley Williams Apparel Store purchases clothing merchandise on account of various vendors. Below is an invoice from Terra Wear. TERRA WEAR ACTION SPORT...
-
Following procedures similar to those for the homogeneous problem (see Section 8.4.1), develop the following stress field for a pressurized hole in an infinite nonhomogeneous medium with moduli...
-
It is said that in ancient times a rich man with a bag of gold coins froze to death while stranded on a frozen lake. Because the ice was frictionless, he could not push himself to shore. What could...
-
In September 2020, Ayayai Corp. commits to selling 149 of its iPhone-compatible docking stations to Better Buy Co. for $16,390 ($110 per product). The stations are delivered to Better Buy over the...
-
What considerations are relevant in selecting a sampling technique in international marketing research?
-
Nelson Industries manufactures a part for a type of aircraft engine that is becoming obsolete. The sales history for the last 10 years is as follows: a. Plot sales versus time. b. Estimate the...
-
J is going to receive a 30-year annuity of 8,500 and L is going to receive perpetuity of 8,500. If the appropriate interest rate is 6%, how much more is L's cash flow worth?
-
Casey Morgan is a single taxpayer, social security number 412-34-5670, who lives at 582 Brockton Lane, Columbus, OH 43081. Casey has income from a job as a manager, interest and dividend income, and...
-
From his office window overlooking the main floor of the Harvard Cooperative Society, CEO Jerry Murphy can glance down and see customers shopping.They make their way through the narrow aisles of the...
-
The Government Accountability Office Report Regulatory Coverage Generally Exists for Financial Planners, but Consumer Protection Issues Remain provides the most current overview licensing...
-
What are the various forms of virtual communication used in modern organizations?
-
How does one choose between communication methods and handle barriers to effective communication?
-
What are the issues surrounding smartphones, social media, and cybersecurity confronting modern organizations?
-
What are the types of interpersonal communication?
-
Question 1 a) What will the following Python statement do? df.drop(df.std()[df.std() == 0].index, axis = 1) Drop both the categorical and numericalvariables with zero variance Drop the variables with...
-
If the jobs displayed in Table 18.24 are processed using the earliestdue-date rule, what would be the lateness of job C? TABLE 18.24 Processing Times and Due Dates for Five Jobs Job C D E...
-
When do you use OLAP?
-
What is a domain?
-
Define a view named Item Order. It consists of the item number, description, price, order number, order date, number ordered, and quoted price for all order lines currently on file. a. Using SQL,...
-
Governor Sophia is in a quandary. She believes everyone should have access to health care and would like to support state policies that make care accessible and affordable. While she supported...
-
What are the benefits and drawbacks of having a health program that varies by state versus having one that is uniform across the country? Do you find that the positives of state flexibility outweigh...
-
Do you think it makes more sense to structure government healthcare programs as entitlements or block grants? What are the economic and healthcare risks and benefits of each approach? Does your...
Study smarter with the SolutionInn App