Could you please tell me which one is correct and explain the reasons? My idea i
ID: 3906073 • Letter: C
Question
Could you please tell me which one is correct and explain the reasons? My idea is A but not for sure, Thanks!
Question 7 [5 marks] Consider the two SQL queries (I and II) given below representing the following query: "Find the names of all people who like every café selling at least one drink they drink." (Note: A person may like a cafe even if it doesn't sell a drink he/she drinks.) Which option regarding these SQL queries is true? ID SELECT name FROM (SELECT name , cafe FROM Drinks, Sells WHERE Drinks. drink-Sells, drink GROUP BY name, cafe) W GROUP BY name HAVING count() = (SELECT count(*) FR0M Likes WHERE Likes.name = w.name) II) SELECT name FROM Person WHERE name NOT IN (SELECT name FROM (SELECT namne,cafe FROM Drinks, Sells WHERE Drinks.drink = Sells. drink AND (name, cafe) NOT IN (SELECT FROM Likes)) W) (a) Only II is correct (b) Both I and II are correct (c) Only I is correct (d) Both I and II are incorrectExplanation / Answer
Answer is as follows :
For the given scenario the second query is correct because in the first query the names are not fetched data about the person that can like cafe even if it doesn't sell a dring becasue the name of persons depend upon drinks and drinks depend upon cafe. So if cafe doesn't sell any drink than the first query can't fetch data.
But in second query the query is run as given information.
So correct option is "a" i.e. Only II is correct.
if there is any query please ask in comments...
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.