database schema - Waynexia888/Strava-Clone GitHub Wiki

Database Schema

users

column name data Type details
id integer not null, primary key
username string not null, indexed, unique
email string not null, indexed, unique
session_token string not null, indexed, unique
password_digest string not null
created_at datetime not null
updated_at datetime not null
  • index on username, unique: true
  • index on email, unique: true
  • index on session_token, unique: true

routes

column name data Type details
id integer not null, primary key
name string not null, indexed, unique
user_id integer not null, indexed, foreign key
distance float not null
duration integer not null
elevation integer not null
description text
created_at datetime not null
updated_at datetime not null
  • index on [:name, :user_id], unique: true
  • belongs_to user
  • has_many locations

workouts

column name data Type details
id integer not null, primary key
date date not null, indexed
workout_type string not null
workout_date datetime not null
user_id integer not null, indexed
route_id integer not null
duration integer not null
description text not null
created_at datetime not null
updated_at datetime not null
  • workout_type: represent biking or running or skiing
  • user_id: belongs_to user
  • route_id: belongs to routes
  • duration: represent the total time in minutes

locations

column name data Type details
latitude integer not null
longitude integer not null
route_id integer not null
created_at datetime not null
updated_at datetime not null

...more schema database will update later...