Ok here's the scenario, you give a PHP front end a list of food you have, say chicken, pineapple, etc etc. I've made a table for ingredients (id, name) and I need to make a way so that once you've told the front end what you do have, a query will return recipes. So if you tell the front end you have; eggs, milk and bread - you're told you can make scrambled egg on toast. However if a recipe required eggs, milk, bread and bacon - because you're missing an ingredient it wouldn't show. I'm thinking the ingredients table should be fine, but not sure how to store ingredients in the recipe record, nor how to search in a way that it ignores things that I couldn't make. I just used food as an example, the end result won't be food. Any help appreciated, not sure how to approach this. Dan
Well, what you can do is to have on you "recipes" table a "ingredients" value with some kind of collection, and then you just need to implement a function to check if you meet all the ingredients listed on the collection Hope it helps
I understand your logic, but I'd like to have the ingredients table as it is, this way I could just select * from this table to make a list of available ingredients.
You can do it by creating the following tables: ingredient recipe recipe_ingredient (intersects recipes with ingredients) Then you could do a select from the recipe_ingredient table that returns the recipe_id of all recipes that don't contain anything but the possible combinations of your ingredient list.