Forum Academy Marketplace Showcase Pricing Features

How to create a "type of type"

Hello the community,

Before everything, thanks so much for this forum, I’m new to Bubble (which is amazing!) and this forum really helps me !

Unfortunately I reached a limit for me and I don’t find any answer here…but my issue seems simple I guess.

Let’s say:

I have two types in my database :

“Basket” with variables like “basket name”,“size”, “color”…

“Fruit” with variables like “type”,“size” , “number”,…

What about if I create a repeating group of the different baskets I have and when I click on one, I’m redirected to a page, where the fruits presents in this basket are displayed.

I’m stuck with this…How do I create sort of sub-types “Fruits” for each of the basket ?

Hope I’m understandable! As a non programmer, Bubble helps me a lot to enter in the logic of programming but not sure I already have the skill to well explain my problem :slight_smile:

Thanks!

Matt

You can put a field on the Basket of type Fruit, and make it a list. Then, you add Fruits to that list. That’ll get you what you’re looking for! (I think :slight_smile: )

1 Like

Clear and simple! I didn’t realize that a field can be a type…thanks!

In Bubble, there are two ways to associate multiple items of one type to another type. (In database-talk, this is called a many-to-one relationship.)

Bubble lets you create a field which contains a list of items. This is NOT standard database methodology. It’s generally frowned up. But Bubble makes it work. However, I would use it only for short lists, and probably when the list is fairly static. And of course, the items in this list can only have one attribute.

Personally, I think I’ll rarely if ever use lists.

The other way is as potentialthings said. Another type, used as a field in the first type. Works beautifullly. This is called a Relational Database.

1 Like

Thanks for the explanation!

One question then, in this setting of Relationnal Database:

In the secondary type, how do I know which thing pertain to which first type ?

To the example of baskets and fruits:

Once I have XX baskets containing XX fruits, in the Fruit database, how do I know which one pertain to wich basket ?

Thanks again for the explanation!

Let’s refer to them as the Many type and the One type. You have one basket with many fruit, so baskets are the One type and fruit are the Many type.

In the Basket type, you will have a field defined as type Fruit, and it will be a list. In the Fruit type, you can have a field defined as Basket, but it will NOT be a list. That’s where you can store the link to the single Basket to which this fruit belongs.

In the workflow that creates the Fruit, be sure you set this field to the appropriate Basket.