Say I have a database of recipes, and I want to search through them based on what ingredients I have.
There should be 3 tables:
Recipes (rid, rname),
Ingredients (iid, iname),
Relationship (rid, iid)
Next, lets imagine I have a recipe for 'toast' and a recipe for 'bread and butter pudding' - Toast has 2 ingredients (bread and butter) - The pudding might have bread and butter, plus flour, eggs and water - so thats 5 in total.
My problem is, structuring an SQL query based on what ingredients are provided in a search. If I submit 3 ingredients in my search - bread, butter and eggs - then (from the 2 recipes discussed) only one result should be produced - Toast! - because there aren't enough ingredients to make the pudding!
So what does such a sql query actually look like? I have tried everything, googled everything and now my brain cannot deal with it anymore.