If I have a database with which can be seen as a recipe database, how can I select all the id's of the recipes I can make with given ingredients, for example if I have ingredient 1 and 4 it will return 3 as that is the only recipe I can make with that.
There will be approximately 50 ingredients and many more recipes.
I see several possibilities like using UNION/several joins, ... but I don't see a straightforward simple solution to this problem.
Recipes Recipes/Ingredients Ingredients
1 1 1 1
2 1 2 2
3 2 1 3
2 3 4
2 4
3 1
3 4
edit/
What I thought of to solve it:
select recipe_id from Recipes
where recipe_id in (
select recipe_id from Recipes_Ingredients where ingredient_Id = 1
UNION
select recipe_id from Recipes_Ingredients where ingredient_Id = 4
)
This will lead to very long queries as my database isn't really about ingredients but about stuff that can have 50 or more of these things in them.