目前,我有两个表,Exercise
和WorkoutPlan
。这些将有多对多的关系。
Exercise
- ID
- Name
...
WorkoutPlan
- ID
- Name
- Exercises (Many to Many with Exercise through WorkoutPlanExercise)
...
在此多对多关系表中,我需要存储有关sets
的信息,例如min_rest
,max_rest
,min_repetitions
和{{1} }}
我被困的地方是,试图找出做到这一点的最佳解决方案。我的第一个解决方案是让另一个表(max_repetitions
)与多对多表(WorkoutPlanExerciseSet
)有多对一的关系,如下所示。
WorkoutPlanExercise
我的第二个解决方案是将所有关于练习集的信息存储在多对多关系表(WorkoutPlanExercise
- ID
- ExerciseID
- WorkoutPlanID
- Sets (One to Many with WorkoutPlanExerciseSet)
WorkoutPlanExerciseSet
- WorkoutPlanExerciseID
- MinRepititions
- MaxRepititions
- MinRest
- MaxRest
)的一行中。例如:
WorkoutPlanExercise
要注意,休息时间和重复次数可以是范围或单个数字。对于第二个解决方案,我想我会创建一个自定义的Django表单字段。
哪个更好?以前是不好的数据库设计?后者是不好的应用程序设计?
如果它有所不同,我希望能够以用户友好的方式轻松显示信息,例如:
WorkoutPlanExercise
ID ExerciseID WorkoutPlanID Sets Repititions Rest
1 1 1 3 10-12, 10-10, 12-12 90-120, 60-90, 30-30