I’m building some application, the involves training programs.
my issue is like this,
A workout could be simple as this:
3 sets of 45 push ups.
so I would just create 2 fields,
sets / count
BUT
a workout could be also:
45 minutes run, 3 sets of 45 pushups, 2 minutes of rope jumping, 150 meter swimming.
so i need to build one table, that would know to store the data as it changes it structure, and later I could still translate it to real data on the gui.
how can i make it efficiently and wisely ?
edit:
To make it a bit clear,
i want to specify to each workout what Ive done in it.
so one workout could be :
3 sets,
first: 45 push ups
second: 32 push ups
third: 30 push ups
and another workout could be:
3 sets of pushups:
first: 45 push ups
second:32 push ups
third: 30 push ups
and also
2 minutes of jumping rope
150 meter swimming
the data isn’t consistence, one set could be a number of push ups, the next could be a time length etc..
I’d say this calls for a 1:n relationship, where there is a master “workouts” table, and one unified “components” table that contains all the activities of a workout.
You’d have your main table
workouts:Then the child table
workout_components:an example value would look like this:
workout table:
workout_components table:
Advantages:
Not limited to specific activities
Easy to query – every question related to how to get something from this kind of data structure has already been answered on SO
Activities can be freely added to each workout