I finally managed to wrap my head around on what things are but I’m having trouble making the connection to list of things.
Reading around, it looks like create some sort of relationship between two different data types. I am confused as to how I can go about doing that and showing it in bubble.
For example, let’s say I have data type: Color and data type: Fruits. I know for Color, I will need a field name called: Color. For Fruit, I will need Name of Fruit.
How do I go about showing the following in a repeating group:
Color - Red
Fruit - Apple, Strawberry
There are some forum apps I’m trying to learn from but it looks like they no longer work
Then we want to associate the red Color Thing (or table row) with different fruits in the app. To do this, we can use a dropdown which does a Search for all of the Colors in our database, and displays the Name field of each Color (so the choices would look like Red, Green, Blue, Purple - if we created those Colors).
Here the User can first enter the name of a Fruit (such as Strawberry), and the dropdown will search for all of the Colors in the database. Since we only created one Color Thing so far (for Red), it will only allow us to pick Red from the dropdown:
Here the text input where we typed ‘Strawberry’ is stored to the Name field, and the Color dropdown where we chose the red Color Thing is saved to this new Fruit’s Color field. In app data it will first look like this:
This looks confusing at first glance because we might feel like the Color column for the strawberry should just say ‘Red’ instead of that very long number. That long number is the red Color Thing’s unique id. Every ‘Thing’ we create is automatically given a unique ID, and that ID links the Red Color Thing we created, to the Strawberry Fruit Thing we created.
We can tell Bubble to display the Color’s Name field, instead of the unique ID field by going to Primary Fields → Color → Name:
Similar to the other repeating group setup, the cell is displaying the Current cell’s Color’s Name. To find the fruits associated with each Color, we can place a text element which Does a Search for Fruits, whose Color = Current cell’s Color:
So, those are different setups but similar results! Here a link to the example app if you’d like to view the workflows or add a few more colors and fruits in preview mode:
Preview:
Editor:
I hope this wasn’t too overwhelming - If anything was confusing, please feel free to let me know and I’ll definitely try to explain more clearly!
I think that’s a really great idea to first get the hang of setting up, and querying data types and fields through an RG. I think I did it this way too!
One thing to mention, in the Fruit/Grocery example, you may have already done this but I would change the ‘Fruit’ field, to be a single Fruit, instead of a list of Fruits - inside the Grocery data type. I also changed it to GroceryItem (just incase that helps see that each GroceryItem as a single thing, not multiple Groceries stored within a single data type). This is because Date of Purchase, Expiration for that GroceryItem’s Fruit Purchased, and Stored Location will probably pertain to one specific GroceryItem purchased (as its reflected in the Excel sheet you already have).
In summary, each GroceryItem will be associated with one type of Fruit (in the Fruit field), but each Fruit could be associated with many different GroceryItems, since anyone can buy the same type of Fruit, on different dates, and store it where they prefer. To show how lists work, we could also choose to store a list of GroceryItems on the Fruit data type:
Here we see two long unique IDs in the GroceryItems field. This is showing that we’ve connected the GroceryItem Things for Peter and Bob, to the Apple Fruit Thing successfully. We can double-check this by changing the Primary Field View for the GroceryItems to be the Buyer’s Name:
And the inner blue repeating group, does a search for the GroceryItems connected to that Fruit. We need two repeating groups because we have multiple Fruits to be displayed (on the outside), and then we want to show multiple GroceryItems, inside each Fruit’s cell. The data setup for the inner repeating group would be:
In the Strawberry first cell, there are no GroceryItems to display in its inner repeating group, because there are no GroceryItems connected with the Strawberry Fruit Thing in our database.
In the second Apple cell, there are two GroceryItems to display in its inner repeating group, because Peter and Bob both bought Apples.
In the third Pineapple cell, there is one Grocery Item to display, because John bought a Pineapple.
The second option setup is almost exactly like the first, with the only difference being about with how the data is queried in the inside GroceryItem repeating group.
Here we’re still doing a Search for Fruits on the outside repeating group:
So this probably isn’t the best example for understanding when to use a list of things and when not to, but I remember that this Twitter example really helped me in the beginning:
In it Vlad explains an overview of his data structure extremely clearly, and when lists of things were used.
Then, this thread is also really awesome in explaining when to create ‘join tables’ in Bubble as well (ignore my posts there and look for Nigel’s!):