Help please understanding linking tables for user types/ roles

Hi, I am trying to understand how bubble connects the database tables. But, as a newbie, I think I might be over thinking it a little.

I have set up 4 tables, each for a different ‘User type’ with each table to manage the bits and pieces for the permission of each user type. Member, Client, Manager, Administrator.

In the ‘User’ table I have a field called Role.

I now have to link each of the tables to the main ‘User’ table, to identify the user as a “User Type” but unclear how bubble does this. Is there a method of linking them or is this simply done by creating a 'User field in each table and pointing it to User table.

What is the best way to define this for the User. I guess I don’t yet understand how you link the tables.

So for example, if I select a User as a “Manager” role how do I then make this link with the “Manager” table to include the user?

Seems like a basic question, but can anyone shed some light on this?

Thank you in advance!!

Steven

Why separate the different types of Users in the first place?

Why not put all users in the default User thing and use a field of ‘Role’ (as you described) as the role defining field?

Are there many fields different between the different users? What kind of bits and pieces you put in the table to manage permissions?

For this specific example, it’s usually best to put roles in the User table, then use "Only when User role is “Admin” and permissions to enforce role privileges.

That said, to answer your question on linking tables: Create a field in a table with the linked table as the type.

So let’s say Manager has its own table. Thing is Manager. Field 1 = First name, type text. Field 2 = User, type User

You can then call in dynamic information like “Current User’s Manager’s First name” or “Search for…”

I’ve created a basic example here, but as it’s temporary I’ll include screenshots as well. If you look at the Data tab you can see I’ve made two tables. Note that when displaying data in tables separate from “Current User” you’ll need to add constraints.

1 Like

Thanks Vincent.

Wow, thank you!! Makes perfect sense when you see it like that. I was over thinking it. The reason I was going to put the user types in separate tables was because I am building a saas / multi-tenant , but I can see I may be making it over complicated. Will play around with these options now I know how it fits together. Thank you.

Steven

1 Like