Hacker News new | ask | show | jobs
by hobs 3687 days ago
Exactly, I dont mean to beat a dead horse, but most bog standard web apps have the quoted items in a db anyway, and these are very common problems.

For example if we have a few tables we can determine which menu items a user could eat:

  users
  user_ingredient_exclusions
  ingredients
  menu_ingredients
  menu

  -- items a user can eat based on not having any items in the excluded   list
  select distinct m.*
  from menu m
  inner join menu_ingredients mi on m.id = mi.menu_id
  left join user_ingredient_exclusions e on e.ingredient_id = mi.ingredient_id
  inner join user u on u.id = e.user_id
  where e.id is null
  and u.id = @id