How to sync two Data types via uniqueID?

Hello.

I have created an app which is a bit different, but has a similar layout like this:

On the left side there is a RepeatingGroup in which you can select a person. The data of this person is then displayed on the right side.
Since the database became very extensive, the RG always took a long time to load all entries. Therefore I created a Data Type “freelancer_slim_index” next to the Data Type “freelancer”. When you create a new freelancer entry all data is stored in “freelancer”. But a few of these data are additionally stored in “freelancer_slim_index”.

But now I get problems to keep the two data types in sync. For example, if I want to change the name of a freelancer afterwards, the entry in “freelancer” is changed. In “freelancer_slim_index” however a new entry is created.

Is there a possibility to synchronize both data types?
Until now I always used the freelancer name to synchronize the data. However, using a uniqueID might be a better way to do this. Is it even possible to sync a uniqueID between different Data Types?

1 Like

Link your datatype ‘Freelancer’ to your datatype ‘Freelancer_slim_index’ in both directions (i.e. have a field for Freelancer_slim_index on your Freelancer datatype, and a field for Freelancer on your Freelancer_slim_index). Don’t use names (i.e. texts) for this, nor unique IDs, but rather use that actual datatypes themselves.

Then anytime you make changes to one, e.g. to the Freelance datatype, also update the Freelancer’s Freelancer_slim_index, and vice versa.

2 Likes

Thank you adamhholmes!
This sounds interesting. However, I still try to wrap my head around this. I have found a short video which describes a similar approach: Bubble.io Tutorial: How to Set a Primary Display Field in Your App - YouTube

However, I do not understand the exact concept behind this. Interlinking both Data Types seem to have no effect on my project. The data of one Data Type don’t show up in the other data type. Or do I need to save the same information on both data types? But what would the benefit be then?

I have created a small test project (if you or someone else want to have a look): Tests002 | Bubble Editor

Thanks in advance!

1 Like

However, I do not understand the exact concept behind this. Interlinking both Data Types seem to have no effect on my project.

You don’t need to link the datatypes in both directions - it all depends on how you plan to access them on your app pages, but there’s no real disadvantage to linking them both ways if they are just a one-to-one relationship.

In your case (at least in the demo app you lined to above), your ‘light’ version datatype and the ‘heavier’ version are almost the same anyway - there’s only 3 more fields on the heavy one than the light one - so there’s really no significant advantage to splitting them into two datatypes.

But if your main datatype had, say, 50-60 fields, including some lists with maybe 20-50 items on each, then it would definitely be worth having an alternative ‘lighter’ version with only a handful of necessary fields to display, rather than loading ALL the data for every item on a page when you only need to show a couple of pieces of data, such as a name and price, for example.

The data of one Data Type don’t show up in the other data type. Or do I need to save the same information on both data types?

Yes, you’ll need to create and update the data on both datatypes whenever you create or update entries. So when you create one, you need to create the other and add the first one to it’s record to link it, then, if necessary, modify the first one to include the second one so they’re linked both ways (if that’s logical for your particular use case).

Once they are linked you can access the data from one by referencing the other: i.e. if your display page has an RG containing your ‘light’ display version of your datatype and you want your user’s to be taken to a page displaying ALL the data from the full datatype for that entry when clicked, you can navigate to the page, and send the current cells ‘light’ datatype’s ‘heavy’ datatype to the page.

That keeps your RGs loading faster as they’re only loading a small amount of data, but you can still access all the data from the other datatype wherever needed.

It takes a little bit more setup to make sure you always update both datatypes anytime you change them, but if your datatypes are heavy and you’re loading a lot of items on your pages it’s worth it to avoid slowing down your app.

3 Likes

Thank you adamhholmes!
I will try this in a test project. It might be to late for my actual project though. My actual project (not the freelancer test project from the link above) is pretty complex and restructuring it might break things apart. But it is definitely good to know how to link two data types. If not for this project, then for future projects.

Thank you very much for you help on this issue! :slight_smile:

1 Like

Hi adamhholmes,
just came across your answer as I struggle with something similar to mirko.heimburger.
For my case I have the data types “Project”, “Property” and “Room”, they are all linked as every project has one property and every property has several rooms.
E.g. I included the “project” data type as a data field in “property”, but when I add data to “property” my data field for the related “project” stays empty. Any ideas how I connect the “project” with “property”?

Thanks and best!