Best Structure for Food Nutrients App

Hello guys, how are you? I have a structural question.

I need to create a table with “nutrients” for foods.

I have another table with those foods.

If you ask me, I would be as rustic as adding columns for all the nutrients to the food table. That way, the form would be huge, some nutrients would be left blank, and storage would be inefficient, I think.

I have also considered creating a third inline table to include within the food form. A table where you can enter and add nutrients to the food along with their quantities. But at this point in the night, my brain isn’t working anymore.

How would you approach this problem?

What I have used..

  • Three tables: Recipes, Materials and Ingredients
  • The material table contains all nutrients based on 100g
  • When you create a recipe, it has the Ingredients table as a child. In this Ingredients table you can add the quantity or weight for the material for as many ingrendients as it’s needed.
  • The Ingredients record has a Ref and it reads the nutritions from the Materials table.

When the Material table has all nutrients you can calculate them in the Ingredients record and based on that, in the Recipe record.

3 Likes

@AleksiAlkio , first of all, I apologize for just now getting around to working on this response.

Given the complexity of the matter, I have created four classification levels for nutrients:

  • Branch (macro and micronutrients)
  • Class (carbohydrates, proteins, fats, vitamins, etc.)
  • Subtypes (e.g., complex carbohydrates, simple carbohydrates, fibers)
  • Variants (e.g., monosaccharides, oligosaccharides, etc.)

It’s not always necessary to use all levels, but it’s good to have them available depending on the case and what is required. The nutrient tables are read-only for users (and quite comprehensive, to be honest). However, feedback is always possible if any data needs to be added or modified.

I have a table of items (where I add data such as weight, brand, packaging, etc.).

Inline, it is possible to access a nutritional information view, which is based on a child table of items. This child table has a Ref field pointing to the items table and is also “is a part of” editable if false. Whenever I need to add a nutrient (as long as it is not repeated), I add it to this table.

I also implemented part of your suggestion: adding nutritional information based on 100g of content. However, I also added the possibility to adjust this amount since some labels provide different parameters.

I decided not to add nutrients as columns in the items table, as my requirements were more complex. Ultimately, I wanted to highlight your comment because it is also a valid solution for other users.

Have a great day!

2 Likes

You’re welcome!

2 Likes

Nutrition Label Analysis and Organization

I must also mention that I’ve been working between yesterday and today, carefully observing nutritional labels, and I’ve noticed some “apples and oranges” mixing. My approach (after quickly reading a book called Fundamentals of Normal Nutrition) is to organize these concepts in order to address the issue seriously.

My conclusions are as follows:

  1. A table is not required for two elements (macronutrients and micronutrients).
  2. A table is not needed for eight elements (proteins, carbohydrates, fats, macrominerals, microminerals, fat-soluble vitamins, water-soluble vitamins, and trace and ultra-trace elements). Although it is necessary to add daily recommended values to macronutrients, since there are only three, this can be managed with the SWITCH() function.
  3. A nutrient table is necessary, as this is where numerical data, not just names, must be included.
  4. It might be beneficial (though not mandatory) to include a table for subtypes, where additional data, besides names, could also be added.
  5. Most nutritional labels are developed from the higher to lower hierarchical taxonomy, so this is the method to approach and validate subtype and variant data, ensuring they do not exceed the main record’s information.
  6. In some cases (micronutrients), it’s impossible to add amounts in the first form. It’s necessary to go to a child form to add amounts of subtypes.
  7. Not all items have the same amount of nutritional information. Therefore, a general overview concludes that there are minimum values covered and a cloud of remaining unreported values. That is, the absence of information does not imply zero but rather missing data.

By clarifying all of this, it is possible to organize a taxonomic and structured nutritional label (with the available data at hand), as long as there is no specific study for each case.

Again, thank you for your input.

1 Like