F
F
FairyFox57002020-02-20 18:21:51
Database design
FairyFox5700, 2020-02-20 18:21:51

Do I need to store the ingredient and product separately in the database?

I have recipes that consist of ingredients -> one-to-many relationship.
And also there are foods that store calorie content and name .
The ingredient actually has to store the product and its quantity and unit of measure .
I need to create a table for the ingredients and will it be a one to one relationship?
Also, for calorie content, you also need to create your own table, which will have a one-to-one relationship with the product?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ronald McDonald, 2020-02-20
@FairyFox5700

An ingredient, for example, can be minced meat, which can contain several products (onions, eggs, bread, whatever), I would make the product and ingredient as one-to-many.
And I would stuff the calorie content into "products".

I
Ivan Shumov, 2020-02-20
@inoise

Oh, my test task) Well, or is it some kind of popular problem.
In fact, this task is not about knowing data structures, but about understanding the data itself and how it will be used (now and in the future). There are several standard outcomes. In any case, it is necessary to understand whether the product differs from the ingredient. As for relationships, it's better to play it safe and use many-to-many relationships for extensibility, but if there are limitations, then they should be clarified with leading questions.
About calories - it's just a number. It can be calculated or fixed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question