I took a database that stores fitness information, and we discussed a specific table and whether it should remain a single table or split into three tables.
Today there is one table: training , which has the following fields
id, exercise_id, reps, weight, date, person_id
So, if I made 2 sets of 3 different exercises in one day, I would have 6 entries in this table for this day. eg:
id, exercise_id, reps, weight, date, person_id
1, 1, 10, 100, 1/1/2010, 10
2, 1, 10, 100, 01/01/2010, 10
3, 1, 10, 100, 1/1/2010, 10
4, 2, 10, 100, 1/1/2010, 10
5, 2, 10, 100, 1/1/2010, 10
6, 2, 10, 100, 1/1/2010, 10
So the question is that in several records there is some redundant data (date, personid, exercise_id), if this should be normalized to three tables
WorkoutSummary :
- id
- date
- person_id
WorkoutExercise :
- id
- workout_id (foreign key in WorkoutSummary)
- exercise_id
WorkoutSets :
- id
- workout_exercise_id (foreign key in WorkoutExercise)
- reps
- weight
I would suggest that the disadvantage is that after this refactoring, the queries will be slower, since now we will need to join 3 tables to make the same query that did not have joins before. The advantage of refactoring allows you to add new fields to the final training level or exercise level in the future without additional duplication.
any feedback on this debate?