mysql - Active Record database Organization -


i'm creating first web app assignment. writing project proposal , part of proposal create schema.

the app concept simple, it's creating workout log, users can create, edit , delete workouts kept in organized log.

i having trouble thinking best way structure database when user wants fetch specific workout, comes exercises , results.

so far i've come layout. guess workouts.exercises.results gather correct information, wanted know if tidier way organize data first time , trying create using best practices.

workouts

column name

id
name
user_id
updated_at

exercises

column name

id
name
workout_id
updated_at

results

column name

id
exercise_id
workout_id
sets
reps
duration
updated_at

as per understanding, workouts has many exercises, exercise has 1 result.

if yes, don't need workout id in result table.

for fetching records workout, use following code:

w = workout.find(workout_id) w.exercises.each |e|    puts "exercise=#{e.name} , result = #{e.result}} end 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -