Since you want a variable quantity of a recipe, you need to first make a presumption that every recipe sums to some quantity like 100 gm. Then while querying for recipes with a different quantity, you scale the ingredients accordingly. For instance, if 2.5 cups of Yeast yields 100 gms of Pizza, 80 gms of Pizza needs 2 cups of Yeast.
In order to achieve this, you can create a "Menu Table" with columns "Menu ID" and "Menu Description". You can have another "Menu Recipe Table" with columns "Menu ID", "Recipe ID" and "Scale Factor ID". Finally you create another table "Scale Factor Table" that maps IDs to scale factors like 0.8(80 gms), 1.2(120 gms), 100(10 Kgs) etc
Now, to answer a query that asks "What ingredients(along with their quantities) are required to make Steak and Mash?", you go into the "Menu Table" and get the ID of the "Steak and Mash" menu item. You use this ID and index into(join) "Menu Recipe Table" and get the Recipe ID of "Mash". Then you index into "Recipe Table" to get all ingredients of Mash. Once you get the ingredient quantities, you scale them based on the scale factor found in the "Menu Recipe Table".
Hope you get the idea.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Since you want a variable quantity of a recipe, you need to first make a presumption that every recipe sums to some quantity like 100 gm. Then while querying for recipes with a different quantity, you scale the ingredients accordingly. For instance, if 2.5 cups of Yeast yields 100 gms of Pizza, 80 gms of Pizza needs 2 cups of Yeast.
In order to achieve this, you can create a "Menu Table" with columns "Menu ID" and "Menu Description". You can have another "Menu Recipe Table" with columns "Menu ID", "Recipe ID" and "Scale Factor ID". Finally you create another table "Scale Factor Table" that maps IDs to scale factors like 0.8(80 gms), 1.2(120 gms), 100(10 Kgs) etc
Now, to answer a query that asks "What ingredients(along with their quantities) are required to make Steak and Mash?", you go into the "Menu Table" and get the ID of the "Steak and Mash" menu item. You use this ID and index into(join) "Menu Recipe Table" and get the Recipe ID of "Mash". Then you index into "Recipe Table" to get all ingredients of Mash. Once you get the ingredient quantities, you scale them based on the scale factor found in the "Menu Recipe Table".
Hope you get the idea.