2

I have these tables:

First table(Recipe table),

Recipe

recipeid(PK,AI)

recipename

ingredients

Second table(Ingredients table),

Ingredients

ingredientid(PK,AI)

ingredientname

quantity

Then a 3rd one for display,

Recipe_ingredients

recipeid(FK)

ingredientid(FK)

quantity

How do i construct another table and its relation to the ingredient table to determine its nutritional value.

Should i add another column for nutrition on my ingredient table? Or create another table for nutrition which holds the ingredient id as FK.

Nutrition

Ingredientid(FK)

Say i am diabetic so i should avoid recipes with high amounts of sugar. So from ingredients... im confused where to move from there.

3
  • 1
    Is your question about the subject matter or about the table design? Nov 30, 2014 at 20:36
  • 1
    I don't understand your table design. I cannot understand what is the meaning of recipe.ingredients columnd and the ingredients.quantity column. Can you tell me about meaning of these olumns?
    – miracle173
    Nov 30, 2014 at 23:14
  • I suggest that you name tables and attributes consistently so it will be either Recipe & Ingredient or Recipes & Ingredients. The first option is better. Nov 21, 2015 at 8:30

2 Answers 2

1

You probably want to have some risk information in your NUTRITION table. Perhaps a text column to describe the risk and a threshold quantity column, which might be optional, to describe what is a safe and an unsafe amount.

The thing you have to decide is whether you want to try to normalize out some other information from your nutrition risk descriptions. For example, do you want to have a MEDICAL_CONDITION table that allows risks to be categorized in terms of what type of person is at risk (e.g. diabetes, nut allergy, lactose intolerance,...)

From a design perspective, we can't answer your question about what is needed. That depends on your business rules and what you want to achieve. We can help with technical design questions based on specific statements of your business rules.

1
  • Would you care to show me the structure of the tables you mentioned? both nutrition and its relation to medical_condition. I think ive grasped what you are trying to convey, but i find it hard to decide the structure of my table. Im referring to the table columns.
    – John
    Feb 10, 2014 at 0:52
0

Not 100% sure what you are trying to achieve, but few notes:

In your proposed Nutrition table the class schema would look like this:

Your version

It would mean "Nutrition utilizes Ingredient" or "Nutrition HAS Ingredient". Which I believe is not what you need.

Link to nutrition table

Instead you need a relation "Ingredient has Nutrition", so that Nutrition is an attribute or a property of Ingredient. If you need reusable nutrition categories, like "Nutrition level A" etc., you may introduce a separate Nutrition table. Then you will have to add NutritionId foreign key to the Ingredient table.

enter image description here

Otherwise it is just enough to add a NutritionValue attribute to the table Ingredient.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.