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_idreferences a given usercoordinateswill be imported to render a map with the workout routedescriptionis not requiredelapsed_timein secondscoordinatesparsed JSON objectstotal_elevationshows the total elevation gained and lost over the course of the workoutdelta_elevationshows the max differential in elevation from any two points in the workoutprivatelets 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 |
routeswill 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_idanduser_idreferenceathletes
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_idreferencesuserroute_idreferencesroutespersonal_recordin 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_idreferencesuserworkout_idreferencesworkout
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_idreferencesuserworkout_idreferencesworkout- index on
[:user_id, :workout_id], unique: true