Struggling to grasp relationships to display things from different types

As a former software engineer, with lots of RDBMS and SQL experience, it’s embarrassing to have to ask this. I’m building a basic app (single page), and can’t seem to debug the displaying of data. The desired functionality is to display for any given User, of list of UserProfile data (e.g. name, avatar, etc.) for other Users who are the primary User’s “Contacts”.

I’ve even installed the Instagram-like template as a separate test app, and tried to replicate its database structures, fields, data values, and workflows, but am getting nowhere. I’ve scoured this forum and can’t find anything this fundamental or relevant.

I’ve got a bare-bones User data type, with only the default fields; email, modified date, created date, and slug. Correspondingly, I’ve got a UserProfiles table, which amongst others, includes the fields:

  • User, (type User)
  • Contacts, (type List of Users)

I start with a Reusable Element; a Group named viewportContacts, with an Element Type of “Group”, and a data source of “UserProfile”.

That contains a Repeating Group, with Type of Content = “UserProfile”, and Data source = blank.

That then contains a Row container, with Type of Content = “UserProfile”, and the Data source = Current cell’s UserProfile

That row container holds another group: “Group Fields container”, with Type of Content = “UserProfile”, and the Data source = Parent Group’s UserProfile

Lastly, this contains two Text elements; First Name, and Modified Date. Each has a dynamic data source = Parent Group’s UserProfile First Name, or Modified Date, respectively.
This roughly mimics the Instagram-like app template offered by Bubble, with one exception;
the Instagram-like app template has a workflow based on a custom state,

I’ve tried replicating that Search as a workflow on Page Load (I’m not using any custom states the way that template app does), but the Editor will not even let me construct that same constraint using my Data Types.

As I’ve said, when previewing, nothing displays. I’ve of course populated the underlying App Data with with dummy entries to display.

If anyone can point me in the right direction, I’d be very grateful.

Have you checked your privacy rules on type User?

Your reusable element which has a datasource type of content set to UserProfile will expect and only allow a Single UserProfile as the datasource because the reusable element functions like a group, popup or floating group, all of which only allow for a single entry to be the datasource.

Your Repeating Group with type of content set to UserProfile will expect a List of UserProfiles (that list can be a single value, but if your datasource you start with is a single value, you must use the operator :convert to list for Bubble to accept the dynamic expression)

Your Repeating Group datasource being empty is one reason no values will be displayed via the repeating group’s child elements, since there are no values to show since the datasource of the repeating group is empty.

That is because your data structure does not include the field of ‘followers’ that the screen shot you provided (from the template?) has.

If what you want to do is show a list of users that are following a particular profile, you need to add to your data structure a field on the UserProfile that would be a list of Users and label it ‘followers’…and remember, no values will show until you add followers to the list in the database.

Best way to approach understanding Bubble database structure as somebody with years of experience with SQL is forget what you know about SQL as it will not translate and focus only on learning how Bubble database structure works.

When I taught Bubble bootcamps, I always knew which student would struggle the most with Bubble database structure, and it was always the data scientist or the experienced SQL database architect.

Like I would tell my students I taught English to, ‘forget your native language and focus on learning the language of English; don’t try to translate everything as many things just won’t translate’.

You can take a basic concept for Bubble database structure.

If I want to find the related values of data type B from one data type A, I have a few options:

On Data Type A put a field that is of type B (if it is a list make it a list)
On Data Type B put a field that is of type A (if it is a list make it a list)

I can then do the following:

  1. Look at data type A field value for type B and show me all the values of type B
  2. Do a search for Type A whose field value of type B is equal to the selected type B I have in a data value storage such as URL, custom state or datasource of another element

Sometimes it helps to draw these out on paper (I use old technologies) in boxes with lines to each other to signal the relationships.

Also, as @msgiblin pointed out, do be aware of Privacy Rules and how they affect visibility of data.

Personally, while building, I don’t worry about Privacy Rules until the end of my build so that they never interfere with my development during the development cycle. It is the most annoying thing in the world to try and debug a feature/function to only realize it is because privacy rules are interfering with data retrieval.

Once I complete the build and test all functions are working properly, I add in the privacy rules and test again to ensure the privacy rules are functioning as expected.

1 Like

First off, thank you. I’m sincerely grateful for the rely and advice (and yes… as Yoda said, I must unlearn what I have learned).

Secondly, I kept banging on it late last night after posting this to the forums, with some success.

I turned off all the Privacy controls that I’d mucked with early last week, and was able to get the Search composed correctly on Page Load (again, mimicking how Bubble’s Instagram template did so). I’m not 100% certain, but I believe the reason I wasn’t able to see some of the Fields while constructing the Search constraints, was because of the Privacy settings?

In this functioning version of Repeating Group, I still have Data source empty, as I suspect it’s getting fed that by the Workflow action: Display list in Repeating Group UserProfile, with the Data source being Search for User Profiles with the Type = UserProfile, and the Constraint = "User is in Search for UserProfiles:each items Contacts

While I’ve got it working via a Repeating Group (only because the was the example I had to go by, for testing purposes), I’d actually prefer presenting the data in a Table. What I need to now figure out is where to get the list of Contacts from, and who’s Data source it is:

  • viewportContacts (the page)
  • a container: Group Table
    or
  • the Table itself: Table Contacts

It might have been.

When debugging, you can use the debugger on the preview and the debugger has an inspect tool that allows you to select an element…so select the repeating group for example and you can inspect the datasource and the related filters etc. Also, when looking at the datasource you can see if there are any privacy rules that are causing fields to be unavailable.