In bubble you can create in the database a list of stuff.
For example: in the “users” table you can have a list called “followers” with a list of that users followers (a list of other users id’s}.
How do I make such data connections with Wappler? In the data types there is no listing option.
Hello,
You store your users in one table, and the followers in another.
In the followers table you just store the follower and the id of the user he is following.
I understand what you mean but won’t this be inefficient when there will be a lot of followers data? So when I need to show the followers of user X, it will have to scan all the followers table and conditionally only get the followers for user X.
No, won’t be inefficient. That is how relational databases work and that is exactly how it is recommended to be done.
It is really not recommended and ineffcient to store comma separated ids of the followers in a single field in the users table.
Maybe in Bubble it was just displayed to the user like that in the UI. In the actual bubble database (which you don’t have access to and can’t see) they were most probably stored in different tables as well.
As JonL says, Bubble uses Postgres and with it, you can define a field that is a list of X. Bubble let’s you manipulate that field through its UI.
Having the USER entity have a field called Followers, which I’m assuming you want constructed as a List of USER, effectively means that there is a parent-child relationship between USER and USER.
I think that this is usually represented in 3rd normal form using a separate table to keep those relationships.
The RDBMS engine is taxed a bit more by CRUDing through this intermediate table but the cleanliness that you get, and the possibility of adding other attributes to the relationship table makes it, to me at least, a much preferred option.
To answer your question, you’d have two tables: USER and USER_FOLLOWER. (Note that the use of capitalization is entirely up to you).
USER will have a Primary Key (identity column) which I’ll call UserID and is typically and INT
The latter will have at least these two columns
Followed User (INT)
Follower (INT)
I think it would be a good practice to create an identity column for this table too.
As a fellow Bubble to Wappler switcher I recognize your question or maybe confusion. I do believe that learning more about proper database design is useful and will help with scaling your application. There is loads on youtube on database design