title: Many to one relationship on a junction table (many to many) or a custom field type?
body: <p>Currently, I have two tables, <code>Exercise</code> and <code>WorkoutPlan</code>. These will have a many to many relationship. </p>
  
  <pre><code>Exercise
      - ID
      - Name
      ...
  
  WorkoutPlan
      - ID
      - Name
      - Exercises (Many to Many with Exercise through WorkoutPlanExercise)
      ...
  </code></pre>
  
  <p>In this Many to Many relationship table, I need to store information about a number of <code>sets</code>,  such as there <code>min_rest</code>, <code>max_rest</code>, <code>min_repetitions</code> and <code>max_repetitions</code>.</p>
  
  <p>Where I'm stuck is, is trying to figure out the best solution to do this. My <strong>first solution</strong> is to have another table (<code>WorkoutPlanExerciseSet</code>) that has a many to one relationship with the many to many table (<code>WorkoutPlanExercise</code>), as shown below.</p>
  
  <pre><code>WorkoutPlanExercise
      - ID
      - ExerciseID
      - WorkoutPlanID
      - Sets (One to Many with WorkoutPlanExerciseSet)
  
  WorkoutPlanExerciseSet
      - WorkoutPlanExerciseID
      - MinRepititions
      - MaxRepititions
      - MinRest
      - MaxRest
  </code></pre>
  
  <p>My <strong>second solution</strong> is to store all the information about the exercise set, in a single row in the many to many relationship table (<code>WorkoutPlanExercise</code>). For example:</p>
  
  <pre><code>WorkoutPlanExercise
  ID      ExerciseID      WorkoutPlanID       Sets        Repititions             Rest
  1       1               1                   3           10-12, 10-10, 12-12     90-120, 60-90, 30-30
  </code></pre>
  
  <p>To note, both the rest time and number of repetitions, can be a range or a single number. For the second solution, I think I would create a custom Django Form Field.</p>
  
  <p>Which is better? Is the former bad database design? Is the latter bad application design?</p>
  
  <p>If it makes any difference, I wish to be able to easily display the information in a user friendly manner, such as:</p>
  
  <pre><code>Example Workout Plan
  Exercise        Sets        Repetitions         Rest
  Pull Ups        3           10 - 12             90 - 120
                              8 - 10              30
                              6 - 8               30
  </code></pre>