Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1)Drinkers who frequent only one bar 3) Bars which serve no beer(s) which Joe li

ID: 3890175 • Letter: 1

Question

1)Drinkers who frequent only one bar

3) Bars which serve no beer(s) which Joe likes (you can use one of the outer joins if you want)

4) Bars which every drinker frequents

5)Drinkers who frequent exactly one bar of bar(s) which Vince does not frequent

6) Bars which no drinker frequents

7) Find Bars which serve all beers that Cabana serves and possibly more

8) Get triples <drinker, beer,bar>   such that drinker likes the beer, it is sold by a bar but the drinker does not frequent that bar (perhaps does not know!)

Beers(name, manf) Bars(name, addr, license) Drinkers(name, addr, phone) Likes(drinker, beer) Sells(bar, beer, price) Frequents(drinker, bar) Underline = key (tuples cannot have the same value in all key attributes)

Explanation / Answer

1)select x.bar, count(distinct x.drinker)
from frequents x, likes y, likes z
where x.drinker = y.drinker and x.drinker = z.drinker
group by x.bar;

3)select bar
from Sells not in (
select bar
from Sells
where beer in (select beer from likes where drinker = 'joe')
);


4)select bar
from frequents b
group by bar
having count(*) = (select count(distinct drinker) from frequents);