"User's Team" or "Team's List of Users"

Hey @forum!

I am struggling with knowing how to best set up my database. I have a Data Type “Users” and a Data Type “Teams”. Each Team is composed of many users and a User belongs only to 1 Team.

Is it better to set a “Team” Field to my User or to set a “List of Users” Field to my Team, or do I have to do both? What would you reccommend? Currently I am doing both and it is becoming very chaotic when I reference the elements in the different dashboards or privacy rules.

I would do both. Either way, you can access the users using the team’s list of users.

In a workflow, I would:

Current user’s team = x team > x team: add current user

1 Like

Doing both like you’ve already seen gets hard to manage. Either way would work fine.

Bubble can operate either way because if you want to show a list of players for a team, you can do a repeating group and make the data source “Current pages Team’s Players” or if you go the other way the data source would be “Do a search for Users” with the constraint “Team = Current page’s Team”

The only possible thing I could think of is what if a User doesn’t actually get assigned to a team like a manager for the league or something so they still need access to view teams. They would have an empty field always with no team but also that’s not a big deal either.

1 Like

hey @tylerboodman thanks for the response. And are you aware in terms of performance (list loading speed), which one would yield better results? “Current pages Team’s Players” or “Do a search for User” with the constraint?

Maybe the “Do a search for User” would be ever so slightly slower but only if you had like thousands of players and your database was huge.

Later on you can always flip this around if there’s really something wrong with the structure. Using the backend workflow and a API workflow you can flip the structure around and modify your app to work with the new structure.

1 Like