Need help in changing data in a list

Hello everyone !

So here is my problem : I’m building an app that help create programs based on exercices. I wish for user to be able to modify a specific exercice in a specific program, but the way I’m doing it, when a user modify an exercice in let’s say program A, it will modify all programs in which this exercice appear, instead of just program A.

I have organized the Database like so :

  • A Data Type “Exercice” : with name, sets, etc… and a Program field which is a list of programs (in which the exercice appear)
  • A Data Type “Programs” : with name, etc… and an Exercice field which is a list of Exercice (to records the exercices in the program)

In the app, I use a custom state to records when the user add or remove exercices from the programs, and a RG to display all exercices of the program.

In the RG, the user can put values in inputs to changes fields of a specific exercice and confirm the change. The problem is that it will change the same fields in all program where the exercice appear.

I can’t wrap my head around it, because it seems like the workflows works well, so maybe it is a problem in the design of the database itself ?

I don’t know if you need more informations or if it is not clear,
Thanks you for your guidance !
Nicolas :slight_smile:

That’s not a problem, that’s how Make changes to a Thing works :slight_smile:
What you are doing is changing an existing instance (exercise item), not creating a copy of it.

I think you should implement something like “variants” to your “Exercice”.
So there is some default variant of an exercise A. When User modifies it - create a new Exercice A.1 and so on.
Within “Exercice” data type you can add a feld like “original exercise” (type = exercise) (to have a link to default variant of the exercise A)

1 Like

Thanks for the quick answer !

It makes sense, so adding a new DataType “Variant_Exercice” which will records the differents variants of a same exercice and making the program display the variant instead of the default exercice would work ?

But the problem I have is that it is destined to a large ase of user, who will create tons of programs and exercices. Won’t it be too costly on the data base to multiplie exercices like that ? They are some field which contains pictures of the exercices in question. Maybe try a way to upload the pictures outside of bubble and just have bubble display them from a link ?

Thanks a lot, I am currently trying it and will come back to share the news !

I think it’s better to show “default” variant for all users. And add an option to check custom variants somewhere else. But it’s up to you.

Of course, if you allow any user to create a new variant - you can get a lot of custom-variants of the same exercise :slight_smile:
Moreover you can get a lot of duplicated variants of same exercise because a lot of users will just create their own variants instead of checking existing.
Bubble is pretty good with holding a lot of items in the DB. But if someday you’ll find your WU consumption is eating your $$$ and there is nothing to optimise - you can switch to some external DB like Xano.

You do not store an image in a DB field. URL of the image is stored there. Images are stored in Amazon S3 storage.

1 Like

Ok thanks!

I’ll be more torougth in the explanation :
the DataType Exercice originally contained these fields :

  • Name
  • Creator
  • Description : Start, Movement, Keypoints, Cueing (1 field for each, so 4 in total)
  • Image 1, 2, 3 (1 field for each, but I guess I can just group them in a list of images)
  • Video_Link
  • Privacy_Patient (yes/no)
  • Verified (yes/no)
  • Type
  • Pattern
  • Body Part
  • Stuff
  • Number_Reps
  • Number_Set
  • Rest_Time
  • Weight
  • Commentary

Some of these fields will change based on what the user fill in the app (number_reps, number_set, time_rest, weight, commentary) while all the other are fixed in the database (users can’t change them once the exercice is created).

So I have divided the fields in two datatype :

  • Exercice (all the fixed fields) + Exercice_Variant (list of)
  • Exercice_Variant (all the field that can vary) + Exercice (so that all variants are attached to a single exercices)

In the datatype Program, I have a List_Exercice and a List_Variants (both List of Exercices and Exercice_Variant respectively)

Do you think it’s a good way to go about it ?

How would you go about it ? Set the RG datasource to show the List_Exercices of the program and add in constraints if there are variants to this exercice in this program ? If yes, show the variant ?

Thanks you for your help and sorry for the long message

Back for the news, it works just fine !
Thanks a lot for your help, you saved me a few days of frustration !

Best regards,
Nicolas

1 Like

Lots of great suggestions in this thread! I wanted to offer some additional thoughts. Similar to a recipe or a product for sale, an exercise would align with an ingredient or SKU, respectively. I mention these as comparisons because the ingredient will always be the ingredient, but will have different quantities in each different recipe (or customization of that recipe), and a Product SKU can be sold for different prices, offered for sale, or price increased, as it shows up on the order. In these examples, we use a 3rd datatype, one of part ingredient & quantity for recipes, and one of part product and price for orders.

I can see an exercise program working the same way:

Datatype: ExerciseActions

Fields:
Exercise (type exercise)
Reps (number)
Sets (numbers)
Resting time (number or time)
Weight (type number; referencing amount of weigt used for reps)

Now you have a datatype specifically for a user called ExerciseRoutine, and it’s a list of ExerciseActions for a particular day.

In this way, users or coaches aren’t creating variables of exercises; theyre instead creating customized routines with that exercise.

I hope this helps you as you think of your approach, and I’m happy to answer questions about this!

2 Likes

Hey!
Thanks for your thoughts.

In my app, I want trainers to create programs for clients, but these programs can also be made publics.

By your approach, I can simply add a field private (yes/no), and if private, the trainer complete a field User to which the program is assigned (as your datatype Exercice Routine in your example). If not, it is visible to all. So I just need to constraint the RG group displaying the programs to filter out the privates ones.

Or you would go with two data type, one for private programs and another for public ones. The final goal for trainers is for them to be able to either create a program from scratch, or to just customize an existing program. I would just need to copy the public program into the private one, and have the user change the parameters.

Which way sound best for you ?

Thanks again!

I would go with your first suggestion (have a Private field of Yes/No) which would certaibly make the data more dynamic, and easier for trainers to flip from one to the other.

As you structure the database, I’d encourage you to look at other exercise apps and websites, especially the well known ones, to get a sense for how they might be handling the structure and build of the data - and hopefully inspire you!

1 Like

I see
Yes that’s the plan, I’m in quite the rush for the developement so I go with the flow, until I get a working app.
I’ll then clean everything correctly when I have more time.

Thanks the both of you for everything ! It helped me greatly !

Best regards,
Nicolas

1 Like