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

**URL:** <https://forum.bubble.io/t/data-structure-for-parent-child-things-and-lists-in-a-repeating-group/97888>\
**Category:** Database\
**Created:** [June 19, 2020, 1:16am UTC](https://forum.bubble.io/t/data-structure-for-parent-child-things-and-lists-in-a-repeating-group/97888 "2020-06-19T01:16:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nosedrop](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nosedrop](https://forum.bubble.io/u/nosedrop)\
**Post date:** [June 19, 2020, 1:16am UTC](https://forum.bubble.io/t/data-structure-for-parent-child-things-and-lists-in-a-repeating-group/97888/1 "2020-06-19T01:16:37Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![ambroisedlg](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ambroisedlg/32/61966_2.png) [@ambroisedlg](https://forum.bubble.io/u/ambroisedlg)\
**Post date:** [June 19, 2020, 2:20pm UTC](https://forum.bubble.io/t/data-structure-for-parent-child-things-and-lists-in-a-repeating-group/97888/2 "2020-06-19T14:20:48Z")

</div>

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

> [@nosedrop](#):
>
> 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

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!

---

<div class="post-metadata">

**Author:** ![nosedrop](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nosedrop](https://forum.bubble.io/u/nosedrop)\
**Post date:** [June 20, 2020, 4:06pm UTC](https://forum.bubble.io/t/data-structure-for-parent-child-things-and-lists-in-a-repeating-group/97888/3 "2020-06-20T16:06:36Z")

</div>

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!
