Database Schema - MichaelSchwar3/logmyjog GitHub Wiki
Database Schema
users
column name |
data type |
details |
id |
integer |
not null, primary key |
email |
string |
not null, indexed, unique |
fname |
string |
not null |
lname |
string |
not null |
password_digest |
string |
not null |
session_token |
string |
not null, indexed, unique |
created_at |
datetime |
not null |
updated_at |
datetime |
not null |
- index on
username, unique: true
- index on
session_token, unique: true
runs
column name |
data type |
details |
id |
integer |
not null, primary key |
run_map |
string |
not null |
name |
string |
not null |
location |
string |
|
distance |
integer |
not null |
duration |
integer |
|
runner_id |
integer |
not null, indexed, foreign key |
completed_run |
boolean |
not null, |
created_at |
datetime |
not null |
updated_at |
datetime |
not null |
runner_id
references users
- index on
runner_id
- optional
duration
- optional
location
friends
column name |
data type |
details |
id |
integer |
not null, primary key |
friender_id |
integer |
not null, indexed, foreign key |
friendee_id |
integer |
not null, indexed, foreign key |
accepted |
boolean |
not null |
created_at |
datetime |
not null |
updated_at |
datetime |
not null |
friender_id
references users
friendee_id
references users
- joins table references
users
- index on
[:friender_id, :friendee_id], unique: true
// We don't need a separate index for friender_id
and friendee_id
because the first index adds it for us.
comments
column name |
data type |
details |
id |
integer |
not null, primary key |
body |
text |
not null, |
author_id |
integer |
not null, indexed, foreign key |
run_id |
integer |
not null, indexed, foreign key |
created_at |
datetime |
not null |
updated_at |
datetime |
not null |
author_id
references users
run_id
references runs
- index on
run_id
- index on
author_id
cheers
column name |
data type |
details |
id |
integer |
not null, primary key |
cheerer_id |
integer |
not null, indexed, foreign key |
run_id |
integer |
not null, indexed, foreign key |
created_at |
datetime |
not null |
updated_at |
datetime |
not null |
author_id
references users
run_id
references runs
- index on
[:cheerer_id, :run_id], unique: true
goals
column name |
data type |
details |
id |
integer |
not null, primary key |
activity |
string |
not null, |
goal_type |
string |
not null, |
goal_target |
integer |
not null |
start_time |
datetime |
not null |
runner_id |
integer |
not null, indexed, foreign key |
created_at |
datetime |
not null |
updated_at |
datetime |
not null |
runner_id
references users