I feel like I haven’t designed my database correctly and would love some guidance!
I have an app that has Challenges, Walks, User Challenges and User Walks.
- Challenges - walks: many to many
- User challenges - walks many to many
- User challenges - user walks: many to many
A challenge contains many walks, walks can be apart of many challenges.
Users create a user challenge by first clicking a challenge, and starting the challenge from that page thus creating a user challenge. The problem I have is relating that new user challenge with the same walks as the Challenge…
I also need to allow people to add a user walk without necessarily having started a challenge, but if they have started the challenge then any time they complete a walk (create a user walk) then it is added to the relating user challenge(s)
I need people to be able to start say 2 user challenges and if those 2 user challenges share the same user walks, for those shared walk(s) to update under both challenges i.e if the user marks the walk as completed in one challenge, it should complete in both challenges.
Struggling to get my head around this but I don’t think i’ve set it up correctly because, when i click a challenge as a user and create a create user challenge record, i can’t add the walks from current challenge to new user challenge?
So when a user signs up, the first see a list of the available challenges (Database is already populated with them) They can choose whether they’d like to undergo one or more of these challenges or not. The point of doing a challenge is to set yourself a goal completion date of completing all walks within that challenge thus completing the challenge.
Each challenge has many walks and a walk can be part of more than one challenge.
Users can also choose not to begin a challenge but simply see a list of all walks irrespective of the challenge the walk is apart of, then choose that walk and set a target completion date for that walk. Then they can mark that walk as completed.
So, if/when a user selects a challenge to begin, they set a target completion date. If before they started that challenge (a challenge can be started any time), they had already marked walks as completed that are also in that challenge, after they have started the challenge, clicking the challenge should show any walk previously completed that’s in the challenge as already completed. This would apply across all challenges where previously completed walks are done.
At the stage where they choose to ‘begin’ a challenge (i.e, setting a target date for it) they have an option of setting it to private, which would mean that anyone that views their profile cannot see that walk / challenge.
I think this is easier than it seems, let me break this out into parts.
The first one is the easiest - walks. Every time a user completes a walk, create a record. A user can have many walks, a walk belongs to one user.
The second is challenges. You’ll need to have user references user: creator and participant. For creators; a user can create multiple challenges, a challenge must belong to one user. For participants; it’s many to many. Many users can participate in many challenges.
Here’s where it gets a bit tricky. When a user joins a challenge, you’re going to create a userChallenge for them. A unique challenge with that user’s specific dates and goals. It should relate to a single user and a single challenge.
When a user completes a walk use the countdown timer bulk action update to add the walk to each userChallenge record that’s relevant (filter out userChallenges by dates, status, etc.). Then add the relevant metrics to the goals.
Hopefully that makes sense!
Hi @jpotts ,
Here is my take about your request, (cloneable)
Walks Challenges (adalo.com)
I would use double 1-to-M to replace M-to-M, as it can be extended to include another 1-to-M, to join 3 collections.
If you need multiple takes, adding index field could be a good idea.
Hey @Erik, thanks for this. The part i’m struggling with implementing here is using the “countdown timer bulk action to update the walk to userChallenge record” - is adding an action to a countdown different to adding one to a button?
Either, way I don’t see a way of updating all user challenges to add the walk that they’re completing to them (if the should be added)?
After watching a quick tutorial on the countdown bulk method - I have this working well!