I’m working on a gym logging app using Core Data model. I’m trying to figure out the best way to design the data model.
I’m thinking I will have 2 entities: Exercise and Routine.
The Exercise entity will have attributes for name, link to pic, etc.
The routine will have attributes for strings containing the exercises, along with the reps and sets worked for that particular entry.
What do you guys think or if you have any suggestions? I’m not sure if this is the correct way to organize my data model.
I currently have all the muscle groups and their exercises in an array loaded from a plist.
It sounds like you’re asking at a pretty high level how you should model your data. There’s no “right” way to do it, but there are general things you can do that will make your life easy and your application efficient.
For example, you would have an
Exerciseentity, which would have attributes likeid,name,description,photo, etc. You’d also have aRoutineentity with attributes likeid,name,description, etc.The tricky part is what the relationship between exercises and routines would be. An exercise in routine A might have a different number of sets and reps than the same exercise in routine B. To keep your model efficient, it might make sense to have another entity that associates a particular exercise with a routine and a number of reps and sets. This might be something like
RoutineEntrywith attributes likeid,reps,sets,sequence, etc. and relationships likeexerciseandroutine.Now the relationships start to become a little clearer. An exercise can be associated with many routine entries. A routine entry has one exercise and one routine. A routine has many routine entries.