F
F
FairyFox57002020-02-06 12:15:10
C++ / C#
FairyFox5700, 2020-02-06 12:15:10

Do I need to store calories, fats, carbs, and proteins separately for recipe and ingredient?

I have a program that calculates the calorie content of recipes that the user has chosen and then calculates the calorie content of all recipes.
What is the best way to organize the recipe and ingredient models so that the fields are not duplicated?
Perhaps some kind of interface is needed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2020-02-06
@FairyFox5700

Recipe -> ingredients, one-to-many relationship.

V
Vasily Bannikov, 2020-02-09
@vabka

Heh, I did this myself.
Removed from the recipe everything related to the attributes of the resulting product and added a field of type result_product_id, in which the result is stored. (although then it will not be possible to make the recipe for cabbage rolls and "lazy cabbage rolls" lead to the same result, although from a certain point of view it is ok)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question