Skip to content
AAfghahi edited this page Sep 21, 2020 · 9 revisions

Postgres Database Schema


users

column name data type details
id integer not null, primary key
username string not null, unique, indexed
email string not null, unique, indexed
password_digest string not null
birthday datetime not null
session_token string not null
first_name string not null
last_name string not null
gender string not null
age datetime not null
weight integer not null
height integer not null
location double/decimal 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
  • gender will have a list of choices.

routes

column name data type details
id integer not null, primary key
start_longitude double/decimal not null,
start_latitude double/decimal not null
end_longitude double/decimal not null,
end_latitude double/decimal not null
route name string not null
activity_type string not null
description text not null
distance integer not null
elevation integer not null
estimated_time datetime not null
user_id integer not null
created_at datetime not null
updated_at datetime not null

workouts

column name data type details
id integer not null, primary key
route_id integer not null, primary key
user_id integer not null, indexed
route_id integer not null, indexed
duration datetime not null
distance integer not null, indexed
elevation integer not null, indexed
sport string not null, indexed
description text not null, indexed
workout_time datetime not null, indexed
created_at datetime not null
updated_at datetime not null
  • index on user_id
  • index on route_id

comments

column name data type details
id integer not null, primary key
user_id integer not null, indexed
workout_id integer not null, indexed
body text not null
created_at datetime not null
updated_at datetime not null
  • index on user_id
Clone this wiki locally