-- ============================================================================= -- XXXXXXXXXXCIS 506 Homework 5 Template -- -- , -- -- --...

1 answer below »
Codes have to be in the txt page


-- ============================================================================= -- CIS 506 Homework 5 Template -- -- , -- -- -- ============================================================================= -- This is submitted as individual work according the Academic Integrity Policy -- and the W.P. Carey Honor Code to the best of my ability." If it is not true, -- state why it is not true. -- ============================================================================= use bbb; -- ---------------------------------------------------------------------------- -- 1 Generate a report that shows two rows, -- the beer with highest calories and beer with the lowest calories -- (Assume there is no possibility of a tie for the lowest or highest calories) -- (_) rows -- ---------------------------------------------------------------------------- -- ---------------------------------------------------------------------------- -- 2 The developers of the BBB app have been requested by the local health -- organization to measure the health hazards of drinking three of ones favorite -- beers per day for a week. Generate a report that shows the total weekly -- calories consumed by each person if they drank three of their favorite beers -- per day for a week. Of course this means that if someone likes four beers, -- the report will show the total of the 4x3=12 beers per day, times 7 days to -- obtain the weekly total. Report should show the name and the weekly total of -- calories consumed in a week for that person -- (_) rows -- ---------------------------------------------------------------------------- -- ---------------------------------------------------------------------------- -- 3 Who should go to the bar_inn? In other words,who likes a beer served there? -- (_) rows -- ---------------------------------------------------------------------------- -- ---------------------------------------------------------------------------- -- 4 Which bars serve beer that dave likes? (no duplicates please) -- (_) rows -- ---------------------------------------------------------------------------- -- ---------------------------------------------------------------------------- -- 5 Which bars serve the beers that people like to drink? -- List by person -- (Perform some sort of join between likes and serves, list each person and the -- bars that serve beers they like to drink) -- (_) rows -- ---------------------------------------------------------------------------- -- ---------------------------------------------------------------------------- -- 6 Modify the previous result, Show a table with a persons name, and the -- number of bars that serve beer that they like to drink. List it in an order -- that makes it easy to see who has the most bar options vs. the least options. -- (_) rows -- ---------------------------------------------------------------------------- -- ---------------------------------------------------------------------------- -- 7 Dave wants invite all his buddies over for beer. -- What beers should he have so his buddies all have a beer they like? -- (_) rows -- ---------------------------------------------------------------------------- -- ---------------------------------------------------------------------------- -- 8 Who frequents the same bar as mike? -- IN other words, who might dave meet at a bar? -- (_) rows -- ---------------------------------------------------------------------------- USE company; -- ---------------------------------------------------------------------------- -- 9 For every employee, list the number of dependents -- List the Employee Lastname and column labeled Number_OF_DEPENDENTS -- (_) rows -- ---------------------------------------------------------------------------- -- ---------------------------------------------------------------------------- -- 10 Examine the branch and customer tables. -- What query can you use to list all cities where there are either branches -- or customers. -- (_) rows -- ---------------------------------------------------------------------------- -- ---------------------------------------------------------------------------- -- 11. Find all customers who have a loan at some branch where "Saul Goodman" -- has a deposit. -- (_) rows -- ---------------------------------------------------------------------------- -- ---------------------------------------------------------------------------- -- 12 Which employees do not have any dependents? -- You are required to use a LEFT or RIGHT OUTER Exclude query -- (_) rows -- ---------------------------------------------------------------------------- USE apps_and_crunchbase; -- ---------------------------------------------------------------------------- -- 13 What are the names of the top 10 most rated apps and how many ratings did -- they have (attribute: rating_count) -- (_) rows -- ---------------------------------------------------------------------------- -- ---------------------------------------------------------------------------- -- 14 Generate a report showing the mean of the average_rating for apps by -- category_primary from highest to lowest mean average_rating. -- (_) rows -- ---------------------------------------------------------------------------- -- ---------------------------------------------------------------------------- -- 15 How many apps have appeared in the top300 table, but not in the apps -- table? -- (_) rows -- ---------------------------------------------------------------------------- CIS 506: Introduction to Enterprise Analytics CIS 506 ©Arizona Board of Regents and Dan Mazzola 1 Homework 5 – SQL Part 2 (Individual Exercise) Objective This exercise will enable you to demonstrate mastery of Advanced SQL queries on a DBMS. Instructions Use the question and answer template provided and paste into MySQL Workbench query tab. Read each of the questions, and use your skills to develop a SQL query that provides the best solution. As is usual, if you need to make reasonable assumptions, please state them clearly. Everything you need to answer these queries will come directly from the lecture and the reading (specifically Lessons 1-14 in Sams, Teach yourself SQL). You may have to experiment and even develop your solution in a step-by-step fashion. If the query seems too complicated, try answering a portion, get success, and then refine. Unlike the previous exercise, some of these may require the use of more than one table and thus may require joins or sub-queries. Ensure you use the more qualified JOIN notation. This means I expect you to ALWAYS use INNER JOIN, LEFT OUTER JOIN, RIGHT OUTER JOIN, instead of just JOIN (even if it works). If you use the fully qualified JOIN notation, you prove that you are learning and you won't be fooled later. Use MySQL workbench and connect to the course server. Develop the SQL solution to your query. Please do not paste the result of the query. However, we would like you to include the answer to a question like number of rows returned by your query. Requirements: 1. Replace , and with appropriate values. 2. You will have a number of questions included as SQL comments, like this: -- ----------------------------------------------------------------------------- -- 0. What bars serve beer? (no duplicates please) -- (_) rows -- ----------------------------------------------------------------------------- 3. Your task is to discover the appropriate query, answer the to question and assumptions and document them like this: -- ----------------------------------------------------------------------------- -- 0. What bars serve beer? (no duplicates please) -- (4) rows -- Assumptions: I assume all bars in our domain are listed -- ----------------------------------------------------------------------------- SELECT DISTINCT bar FROM serves; 4. Please ensure your query is formatted nicely, as shown above. You can use the broom icon to beautify your queries. CIS 506: Introduction to Enterprise Analytics CIS 506 ©Arizona Board of Regents and Dan Mazzola 2 5. Do not forget to answer short questions by replacing the underscore inside the parenthesis; for example, "(_) rows" becomes "(4) rows" as shown below. 6. If you need to make and document any assumptions, use a comment as depicted. Do not make trivial assumptions like the one above; it is for illustrative purposes, only use assumptions if required. 7. Aside from what is described above, do not modify the template, leave it as is. If you follow these procedures, I will be able to run all of your queries WITHOUT modification by pasting your solution into my query processor. If I have to make changes to get your queries to run properly, significant deduction will result. 8. When complete, save the document as "Homework5.sql" and upload to the link on the course website. Rubric Your exercise will be graded according the rubric shown on the course website, Partial credit can be earned, so submit a partial solution if you get stuck. bbb.xlsx Copyright2016,ABORandDanMazzola name beer name bar beer cal carb alc name age cell bar address dave coors dave dash_inn bud 145 10.6 5.0 dave 21 555-1234 bar_inn 123Millave mike bud sally bar_inn coors 149 12.2 5.0 gary 23 555-2345 dash_inn 234Millave linda coors mike dash_inn miller 143 13.1 4.7 linda 27 555-3456 drop_inn 345Millave gary miller linda walk_inn mike 24 555-4567 walk_inn 456Millave mike miller mike bar_inn sally 28 555-5678 dave bud gary drop_inn sally miller dave drop_inn sally coors gary dash_inn name buddy bar beer sally linda bar_inn bud linda sally walk_inn coors mike dave dash_inn bud gary linda drop_inn bud mike linda dash_inn miller dave gary walk_inn miller dave linda drop_inn coors dave mike dash_inn coors bar TheBBB(Beer,Bars,andBuds)Entity-RelationshipDiagramandRelations(tables) likes frequents servesbuds beer person Daniel Mazzola Copyright, Dan Mazzola and ABOR
Answered 2 days AfterSep 13, 2021

Answer To: -- ============================================================================= -- XXXXXXXXXXCIS...

Neha answered on Sep 16 2021
158 Votes
-- =============================================================================
-- CIS 506 Homework 5 Template
--
-- ,
--
--
-- =============================
================================================
-- This is submitted as individual work according the Academic Integrity Policy
-- and the W.P. Carey Honor Code to the best of my ability." If it is not true,
-- state why it is not true.
-- =============================================================================
use bbb;
-- ----------------------------------------------------------------------------
-- 1 Generate a report that shows two rows,
-- the beer with highest calories and beer with the lowest calories
-- (Assume there is no possibility of a tie for the lowest or highest calories)
-- (_) rows
-- ----------------------------------------------------------------------------
select beer, cal from beer where cal= ( select max(cal) from beer)
union all
select beer, cal from beer where cal= ( select min(cal) from beer);

-- ----------------------------------------------------------------------------
-- 2 The developers of the BBB app have been requested by the local health
-- organization to measure the health hazards of drinking three of ones favorite
-- beers per day for a week. Generate a report that shows the total weekly
-- calories consumed by each person if they drank three of their favorite beers
-- per day for a week. Of course this means that if someone likes four beers,
-- the report will show the total of the 4x3=12 beers per day, times 7 days to
-- obtain the weekly total. Report should show the name and the weekly total of
-- calories consumed in a week for that person
-- (_) rows
-- ----------------------------------------------------------------------------
select ML.Name, SUM(ML.totalcal)*7 AS WeeklyConsumedCalories
from (
Select pr.name, count(li.beer)*3 * br.cal as totalcal
from person pr
inner join likes li on li.name = pr.name
inner join beer br on li.beer=br.beer
group by pr.name,li.beer
) ML
group by ML.name;

--...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here