How should I set up my app?

Hi there. I am looking for some advice on how to set up my app. The app allows a user to create multiple “groups”. Each group has information unique to it (e.g. description, address, etc.).

After a user logs in, they would need to select which group they are looking to update and then anything they enter would only apply to the selected group. But I’m not sure how to set up the database and navigation to accomplish this.

For example,

  1. User logs in
  2. selects the group they want to update
  3. they input new (udpate) information

How do I assign the updates to only the group selected?

  1. User selects another group (group 2)
  2. User inputs new data for that group (Group 2)

How do I assign the updates to only the group selected (group 2)?

Hello @newcoder

Perhaps the concept of a state value should help here.

Place the selectedGroup in a place where it is held as a “state”. You can do this in several ways but the easiest to implement could be a custom state.

Explore how custom states work in Bubble :smiley:

How are you allowing the user to select the group to update? Likely it is with a dropdown element…so, in workflow action simply run an action to make changes to a thing and the thing would be the dropdowns value

Correct. Through a dropdown element. The difficulty may be that I have multiple things the user can do to the selected group. For example, if the user chooses “group 1” they can…

  1. Add things to the group (e.g. like names of team members)…stored in a member table
  2. Assign different things to a group (e.g. like assignments)…stored in an assignments table
  3. etc.

So to make sure the team members and assignments are associated with the selected group and only that group, do I need to make a giant table to house all the information for that group? Or should I separate the tables and have a field in the table to list all the groups that have those assignments?

I guess I’m having trouble envisioning how the workflow and databases are aligned so that the information is stored for that selected team

Hi there! You can use a Custom State on the Index page (Or whatever is the name of the page) with the kind of data “Group”.

Here’s how i’d do it

1 - User logs in
2 - Conditional workflow where if the Index Custom State with the group is empty, shows a popup with the dropdown
3 - After selecting the group, user clicks a button that would set the Custom State with the selected group
4 - Now, every workflow you’l do will refer to the Index Custom State

@newcoder you do not need to have a custom state for this. The dropdown element will already have the selected value stored and available for a source of reference in dynamic expressions. There is absolutely no need to run a workflow to save a custom state of a value that you already have access to. You also do not need a separate page, and that would actually just make for a poor UX.

To your actual questions.

When making relationships via the database between different data types you have created, there are different approaches, such as 1:1 relationships, or 1 to many or many to many…basically when you have a Group data type and you want to know which members are part of that Group, you have two choices, one group can have a list of many members or one member can have a list of many groups.

For this, I’d say put the list of members onto the group data type if the list of members is not going to exceed 50 items or so (lots of posts in forum speaking on performance of list fields). If however, you expect the number of members of one group to exceed 50 on a regular basis, but users will not be members of more than 50 groups, then you put a list field for groups onto the User data type.

For the assignments, you can do a 1:1 relationship, where the assignment data type has a data field for group, so one assignment will only ever have one group related. If you wanted to show a user all the assignments for that group, just do a search for Assignments with a constraint of Group field = selected group (you’d have to come up with the way you want to know which group the user is looking for the assignments of which is part of you UI and UX approach).

But again, absolutely no need for custom states. Your issue is more about database structure, so you may want to review some resources on that.

Very true in my case! The worflow and database design seem to be key. Close second might be privacy settings for me. Thanks for your tips BTW! I’m trying out the suggested approaches and hope to upate here to see what worked (or didn’t!).

For me, I build the app first, make sure everything functions, then I implement the privacy settings and test again to make sure privacy settings function as expected.

They all might. In Bubble there are many ways to achieve the same result, however, there is often one that may be the most optimized/performant.