Data structure for parent-child things and lists in a repeating group

Hi, I will make this example scenario as simple and clear as possible.

Let say you have Type recipe. Recipes have 3 fields. One, list of Type Ingredient. Two, list of Numbers(representing 2 apples, 2 potatoes, etc.). Three, Units.

An example Recipe looks like this in the database:
Number Units Ingredients
1,3,1 Tsp, Cup, NULL Salt, Butter, Pumpkin

(I realized after posting that you cant see the spaces above, so imagine it as if each list is in one box of the field/one cell in a spreadsheet. Numbers has a list of numbers in the cell, Units has a list of units in one cell, Etc Etc.)
So the first ingredient in this recipe would look like: 1 Tsp “of” Salt

As you can see, the first entry in a given Recipe’s Number and Units corresponds to the first Ingredient in that Recipe’s list of ingredients

My first question is what are alternative data structures I can use so that I can achieve having different Numbers and Units of Ingredients in different Recipes (this isn’t mandatory but may be to achieve part 2 of my question )

My second question involves repeating groups. I want to display and most importantly edit in each row of a repeating group something like this:

1 Tsp Salt Remove (or add search-add and search-remove groups)
3 Cups Butter Remove
1 Pumpkin Remove

So when I change the Units for example, I can just click a “Save” button and if its the 3rd ingredient in that Recipe, the 3rd Unit is changed. I am currently able to display the Number, Units, and Ingredients of a recipe in 3 separate repeating groups (each group’s type of content is Number, Unit, and Ingredient, respectively), so it looks like one repeating group to the user visually. However, if I take an ingredient out, I don’t know how to edit the lists of Units and Numbers.

Thank you for the time to read this and respond!

Hey @nosedrop

I think you could have a much simpler data structure:

  1. Two option sets:
  • IngredientOptions where you list all ingredients
  • UnitOptions where you list all different units
  1. a data type Ingredients, with the following fields:
  • Number (of type number, not a list)
  • Ingredient (of type IngredientOptions, not a list).
  • Units (of type UnitOptions, not a list)
  1. a data type Recipe, with only one field Ingredients (list of Ingredients)

That means each recipe can have multiple ingredients, each one having an ingredient, a unit and a number of units

With the data structure above, this becomes very straightforward:

  1. Set your RG to 1 column and 3 rows, and data source to Current Recipe’s Ingredients

  2. In the first cell, include the following elements from left to right:

  • a dropdown: Set it to Current cell’s Number
  • two text elements: Set those to Current cell’s Unit and Current cell’s Ingredient
  • an icon (fa-close)
  1. Build workflows so that:
  • when dropdown’s value is changed > make changes to Current cell’s Ingredient: number = this dropdown’s value
  • when icon is clicked > delete Current cell’s Ingredient

Hope that helps!

Thank you so much for helping me with the solution. I figured out something similar involving simplifying my database. I used something similar to an ingredient option thing. Speaking in Java terms, I had 3 arrays each of 3 classes and when i take out the 6th item of one of the arrays(lists) I would need to do the same to the others which was very complicated to do in the workflow, so the solution which was basically yours was to make the 3 things/classes all one class. It works great. Now onto the next problem of the day!
Thanks again!

1 Like