I have a solution to my problem, but it’s cumbersome and ultimately static. Am I missing something?
There are many “recipe” example apps I found, which associate a number of foods to a dish. This is an easy thing to do in the relational database.
Food:[name,nutrient1,nutrient2,…] → Dish:[name,(Food,Food,Food…),nutrient1 sum, nutrient2 sum,…]
But a real recipe has a quantity of each item. I don’t see any way to set this up in Adalo except to add an intermediary database with a line for every entry in every dish, with a quantity, subtotaling the nutrients, then doing a total of all nutrients when the dish is built.
Food:[name,nutrient,nutrient,…] → Dish Item:[quantity, Dish, Food, qty.nutrient1, qty.nutrient2,…] → Dish:[name, Dish Item, Dish Item, Dish Item,… , nutrient1 total, nutrient2 total,…]
So the user picks a list of foods for the dish, and they are added to the “Dish Item” collection each with quantity 1. Then the user sets the real quantity for each Dish Item and as each is saved I have the nutrient subtotals for the Dish Item computed and saved. Then the user clicks “Update Dish and Save” and only then are all the sums totaled for each nutrient.
I’m doing a pretty serious diet tracking app. Over 40 nutrients are being tracked. Writing update lines for each nutrient in three different databases has been cumbersome, and debugging is going to be a pain. The “Dish Item” database will get large with data not needed later. And I’m left with static data - if the food database is updated none of the old meals update.
Did I miss some way to have different quantities for items in a many-to-one relationship, and to use that to drive calculations on related sub-data?