Question Recipes relationship diagram module.

Hav0c

Member
Joined
Jul 15, 2011
Messages
5
Programming Experience
3-5
Hello people.
I have been struggling for some time now with drawing up a relationship diagram module for my scenario.

I have three tables as of now.
1) Recipes

2) Ingredients

3) RecipesIngredients
Recipes --(one to many) ---|> RecipesIngredients <|-----(many to one) --- Ingredients

Some of the Recipes
[TABLE="width: 500"]
[TR]
[TD]IDR
[/TD]
[TD]Name
[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Platter (pre defined ingredients)[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Salad (pre defined ingredients)[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Sausage[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Chips[/TD]
[/TR]
[/TABLE]

Some of the Ingredients
[TABLE="width: 500"]
[TR]
[TD]IDI
[/TD]
[TD]Name
[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Lettuce[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Potatoes[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Tomato[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Meat[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Spices[/TD]
[/TR]
[/TABLE]

What I can do is brake EVERY Recipe down to their basic Ingredients like

RecipesIngredients
[TABLE="width: 500"]
[TR]
[TD]ID
[/TD]
[TD]IDR
[/TD]
[TD]IDI
[/TD]
[TD]Quantity
[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]1[/TD]
[TD]5[/TD]
[TD]1[/TD]
[/TR]
[/TABLE]

For example to make a Platter one would need Lettuce, Tomato, Meat and Spices.


The problem.

a Salads ingredients are Lettuce and Tomato and that of Sausages are Meat and Spices.
So as a matter of fact a Platter is made up of both a Salad and Sausages which is both in my Recipes table.


The questions.

Should I brake every Recipe down to their bare Ingredients
OR
Is there a way to make the RecipesIngredients reflect more than one Recipes ID, take into consideration not all Recipes uses Recipes that are allready in the Recipes table.


Achievement.

What I am trying to achieve is when the user select a Platter.
They only see the Salad and Sausage being it an image or just the name on a labe BUT when they select the Salad or the Sausage they will see their Ingredients.
 
Back
Top