Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I was hoping I could get some advice on my table structure. Im writing a simple workout tracker for me and my buddies. These are the requirements:

  • Multiple users
  • A user can have multiple workouts
  • A workout has multiple sets
  • A set can have multiple users

I have a way to accomplish what I need to but I feel like theres a much simpler way that Im missing.

tbl_user

| UserId |   Name |
-------------------
|      1 |  John  |
|      2 |  Greg  |

tbl_workout

| WorkoutId |
-------------
|     1     |
|     2     |

tbl_user_workout

| WorkoutId | UserId |
----------------------
|     1     |    1   |
|     2     |    1   |

tbl_set

| SetId | WorkoutId |
---------------------
|   1   |      1    |
|   2   |      1    |

tbl_user_set

| UserSetId | SetId | UserId | Reps | Weight |
----------------------------------------------
|     1     |    1  |    1   |  20  |   50   |
|     2     |    1  |    2   |  15  |   60   |

I figure this way I could get:

  • A users sets with user->userset
  • A users workouts with user->userworkout
  • A workouts sets with workout->set

Is this structure logical?

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.