JoeyMBrown / bellator

An application used to log workouts.
0 stars 0 forks source link

DBML #8

Open JoeyMBrown opened 1 month ago

JoeyMBrown commented 1 month ago

// Docs: https://dbml.dbdiagram.io/docs

Table follows {
following_user_id integer
followed_user_id integer
created_at timestamp
}

Table users {
id integer [primary key]
username varchar
role varchar
created_at timestamp
}

Table posts {
id integer [primary key]
title varchar
body text [note: 'Content of the post']
user_id integer
status varchar
created_at timestamp
}

Table workouts {
id integer [primary key]
workout_type_id integer
user_id integer
name varchar
description varchar
created_at timestamp
}

Table exercises {
workout_id integer
exercise_type_id integer
user_id integer
id integer [primary key]
name varchar
description varchar
created_at timestamp
}

Table exercise_types {
id integer [primary key]
name varchar
description varchar
created_by_user_id integer
created_at timestamp
}

Table workout_types {
id integer [primary key]
name varchar
description varchar
created_by_user_id integer
created_at timestamp
}

Table exercise_sets {
  id integer [primary key]
  exercise_id integer
  user_id integer // This is redundant but will make it 1 join for all a user's sets
  repitions integer
  weight integer // Store all weight as lbs - value objects or model attributes for conversions?
}

Ref: posts.user_id > users.id // many-to-one

Ref: users.id < follows.following_user_id

Ref: users.id < follows.followed_user_id

Ref: users.id < workouts.user_id

Ref: users.id < exercises.user_id

Ref: workouts.id < exercises.workout_id

Ref: exercise_types.id < exercises.exercise_type_id

Ref: workout_types.id < workouts.workout_type_id 

Ref: "exercise_sets"."exercise_id" < "exercises"."id"

Ref: "exercise_sets"."user_id" < "users"."id"```
JoeyMBrown commented 1 month ago


Table follows {
  following_user_id integer
  followed_user_id integer
  created_at timestamp
}

Table users {
  id integer [primary key]
  username varchar
  role varchar
  created_at timestamp
}

Table posts {
  id integer [primary key]
  title varchar
  body text [note: 'Content of the post']
  user_id integer
  status varchar
  created_at timestamp
}

Table workouts {
  id integer [primary key]
  workout_type_id integer
  user_id integer
  name varchar
  description varchar
  created_at timestamp
}

Table exercises {
  exercise_type_id integer
  id integer [primary key]
  name varchar
  description varchar
  created_at timestamp
}

Table workout_exercises {
  id integer [primary key]
  workout_id integer
  exercise_id integer
  created_at timestamp
}

Table exercise_types {
  id integer [primary key]
  name varchar
  description varchar
  created_by_user_id integer
  created_at timestamp
}

Table workout_types {
  id integer [primary key]
  name varchar
  description varchar
  created_by_user_id integer
  created_at timestamp
}

Table exercise_sets {
  id integer [primary key]
  workout_exercise_id integer
  repitions integer
  weight integer // Store all weight as lbs - value objects or model attributes for conversions?
}

Ref: posts.user_id > users.id // many-to-one

Ref: users.id < follows.following_user_id

Ref: users.id < follows.followed_user_id

Ref: users.id < workouts.user_id

Ref: exercise_types.id < exercises.exercise_type_id

Ref: workout_types.id < workouts.workout_type_id

Ref: "workouts"."id" < "workout_exercises"."workout_id"

Ref: "workout_exercises"."exercise_id" < "exercises"."id"

Ref: "workout_exercises"."id" < "exercise_sets"."workout_exercise_id"
JoeyMBrown commented 2 days ago

Add new points table, add time_spent field to workout sets - need alterantive solution for distance / not weight related exercises.



Table follows {
following_user_id integer
followed_user_id integer
created_at timestamp
}

Table users {
id integer [primary key]
username varchar
role varchar
created_at timestamp
}

Table posts {
id integer [primary key]
title varchar
body text [note: 'Content of the post']
user_id integer
status varchar
created_at timestamp
}

Table workouts {
id integer [primary key]
workout_type_id integer
user_id integer
name varchar
description varchar
created_at timestamp
}

Table exercises {
workout_id integer
exercise_type_id integer
user_id integer
id integer [primary key]
name varchar
description varchar
created_at timestamp
}

Table exercise_types {
id integer [primary key]
name varchar
description varchar
created_by_user_id integer
created_at timestamp
}

Table workout_types {
id integer [primary key]
name varchar
description varchar
created_by_user_id integer
created_at timestamp
}

Table exercise_sets {
  id integer [primary key]
  exercise_id integer
  user_id integer // This is redundant but will make it 1 join for all a user's sets
  repitions integer
  weight integer // Store all weight as lbs - value objects or model attributes for conversions?
  time_spent time
}

Table exercise_points {
  id integer [primary key]
  exercise_id integer
  points integer
  repitions integer
  time_spent time
  created_at timestamp
}

Ref: posts.user_id > users.id // many-to-one

Ref: users.id < follows.following_user_id

Ref: users.id < follows.followed_user_id

Ref: users.id < workouts.user_id

Ref: users.id < exercises.user_id

Ref: exercise_points.id < exercises.id

Ref: workouts.id < exercises.workout_id

Ref: exercise_types.id < exercises.exercise_type_id

Ref: workout_types.id < workouts.workout_type_id 

Ref: "exercise_sets"."exercise_id" < "exercises"."id"

Ref: "exercise_sets"."user_id" < "users"."id"
JoeyMBrown commented 1 day ago

New concept of generalizing exercise sets and their measurements. Shuffling to remove redundant data points and to begin thinking about points and how they will be tracked both historically and as a table that is editable.


id integer [primary key]
username varchar
role varchar
created_at timestamp
}

Table workouts {
id integer [primary key]
workout_type_id integer
user_id integer
name varchar
description varchar
created_at timestamp
}

Table exercises {
workout_id integer
exercise_type_id integer
id integer [primary key]
name varchar
description varchar
created_at timestamp
}

Table exercise_types {
id integer [primary key]
name varchar
description varchar
created_by_user_id integer
created_at timestamp
}

Table workout_types {
id integer [primary key]
name varchar
description varchar
created_by_user_id integer
created_at timestamp
}

Table exercise_logs {
  id integer [primary key]
  exercise_id integer
  exercise_metric integer // Value (5 miles, 10 minutes, etc)
  metric_unit_id string // Unit of Measure, (Miles, Minutes, Lbs, etc)
  exercise_points decimal
}

Table metric_units {
  id integer [primary key]
  name string // Miles, Lbs, Minutes, Hours
  description string
}

Table exercise_points {
  id integer [primary key]
  exercise_id integer
  points integer
  exercise_metric integer
  metric_unit_id integer
  created_at timestamp
}

Ref: users.id < workouts.user_id

Ref: exercise_points.exercise_id < exercises.id

Ref: workouts.id < exercises.workout_id

Ref: exercise_types.id < exercises.exercise_type_id

Ref: workout_types.id < workouts.workout_type_id 

Ref: "exercise_logs"."exercise_id" < "exercises"."id"

Ref: metric_units.id < exercise_logs.metric_unit_id

Ref: metric_units.id < exercise_points.metric_unit_id
JoeyMBrown commented 1 day ago

Changes to treat exercise points table very similar to how pricing would be treated in a price / order scenario. This feels close to goal result. -- Not sure exercise types table makes sense here, unless used as some sort of "tag" for filtering.


Table users {
id integer [primary key]
username varchar
role varchar
created_at timestamp
}

Table workouts {
id integer [primary key]
workout_type_id integer
user_id integer
name varchar
description varchar
created_at timestamp
}

Table exercises {
workout_id integer
exercise_type_id integer
id integer [primary key]
name varchar
description varchar
created_at timestamp
}

Table exercise_types {
id integer [primary key]
name varchar
description varchar
created_by_user_id integer
created_at timestamp
}

Table workout_types {
id integer [primary key]
name varchar
description varchar
created_by_user_id integer
created_at timestamp
}

Table exercise_logs {
  id integer [primary key]
  exercise_id integer
  exercise_metric integer // Value (5 miles, 10 minutes, etc)
  metric_unit_id string // Unit of Measure, (Miles, Minutes, Lbs, etc)
  exercise_points decimal
}

Table metric_units {
  id integer [primary key]
  name string // Miles, Lbs, Minutes, Hours
  description string
}

Table exercise_points_history {
  id integer [primary key]
  exercise_id integer
  points integer
  exercise_metric integer
  metric_unit_id integer
  start_date timestamp
  end_date timestamp
  created_at timestamp
}

Ref: users.id < workouts.user_id

Ref: exercise_points_history.exercise_id < exercises.id

Ref: workouts.id < exercises.workout_id

Ref: exercise_types.id < exercises.exercise_type_id

Ref: workout_types.id < workouts.workout_type_id 

Ref: "exercise_logs"."exercise_id" < "exercises"."id"

Ref: metric_units.id < exercise_logs.metric_unit_id

Ref: metric_units.id < exercise_points_history.metric_unit_id