Schema - KaminKevCrew/Striva GitHub Wiki

Overview

A user will have a profile with listed stats calculated from all workouts. A user can post a workout of type "Row", "Swim" or "Cycle".

users

column name data type details
id integer not null, primary key
username string not null, index
gender string not null, includes: ['M', 'F', 'Non-Binary', 'Other']
session_token string not null, uniqueness: true
password_digest string not null
created_at datetime not null
updated_at datetime not null
  • index on username, unique: true

workouts

column name data type details
id integer not null, primary key
user_id integer not null, foreign key
workout_type string includes: ["Cycle", "Row", "Swim"]
title string not null
distance integer not null, default: 0
description string
total_time integer not null, default: 0
total_elevation integer not null, default: 0
delta_elevation integer not null, default: 0
date integer not null
coordinates string not null
personal_record boolean includes: [true, false]
private boolean includes: [true, false]
  • user_id references a given user
  • coordinates will be imported to render a map with the workout route
  • description is not required
  • elapsed_time in seconds
  • coordinates parsed JSON objects
  • total_elevation shows the total elevation gained and lost over the course of the workout
  • delta_elevation shows the max differential in elevation from any two points in the workout
  • private lets the user choose whether or not they want to share their workout

routes

column name data type details
id integer primary key, not null
coordinates string not null
title string not null
  • routes will be two or more points to determine a specific route or segment. will be determined based on frequently run routes by other users.

Bonus

Bonus objectives: Adding friends, so that different users can keep track of the workouts their friends are doing. segment_records so that users can keep track of their fastest times over a given segment of their workouts. comments so that friends can comment on each other's workouts likes so that friends can like each other's workouts.

friends

column name data type details
id integer primary key, not null
user_id integer foreign key, not null
follower_id integer foreign key, not null
  • index on [follower_id, user_id], unique: true
  • both follower_id and user_id reference athletes

route_records

column name data type details
id integer primary key, not null
user_id integer foreign key, not null, indexed true
route_id integer foreign key, not null, indexed true
personal_record integer not null
  • user_id references user
  • route_id references routes
  • personal_record in seconds to complete route

comments

column name data type details
id integer primary key, not null
user_id integer foreign key, not null, indexed true
workout_id integer foreign key, not null, indexed true
comment string not null
  • A user can comment on workout
  • user_id references user
  • workout_id references workout

likes

column name data type details
id integer primary key, not null
user_id integer foreign key, not null, indexed true
workout_id integer foreign key, not null, indexed true
  • A user can like a workout
  • user_id references user
  • workout_id references workout
  • index on [:user_id, :workout_id], unique: true