Check if restaurant sells only the pizzas that customer likes using SQL
I'd logically do (2) first with a join ("Restaurant has the same location as customer"), and then eliminate the results with a restaurant that sells a pizza that the customer doesn't like:




create table customers(
  cname text
 ,area text
);

insert into customers(cname,area)
values('alice', 'east')
     ,('bob', 'north')
     ,('james', 'central');

create table restaurants(
  rname text
 ,area text
);

insert into restaurants(rname,area)
values('Pizza Place', 'east')
     ,('Pizza Local', 'west')
     ,('Pizza World', 'central');

create table sells(
  rname text
 ,pizza text
 ,price int
);

insert into sells(rname,pizza,price)
values('Pizza Place', 'hawaiian','10'),
  ('Pizza Local', 'pepperoni','11'),
  ('Pizza World', 'chicken','12'),
  ('Pizza World', 'meat feast','13'),
  ('Pizza World', 'veggie','8');

create table likes(
  cname text
 ,pizza text
);

insert into likes(cname,pizza)
values ('alice', 'hawaiian')
      ,('bob', 'pepperoni')
      ,('james', 'chicken')
      ,('james', 'meat feast');






select *
from customers c join restaurants r using (area)
where not exists( select pizza from sells where rname=r.rname
                  except
                  select pizza from likes where cname=c.cname );



area | cname | rname      
:--- | :---- | :----------
east | alice | Pizza Place



dbfiddle here

To get the list of customers just change select * to select distinct cname