Schema - Atar97/FSP 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 |
DOB |
datetime | not null |
gender |
string | |
session_token |
string | not null |
password_digest |
string | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
city |
string | |
state |
string | - |
- index on
email, unique: true
state
will be allowed to be null or in the 50
Routes
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
creator_id |
integer | not null, indexed, foreign key |
city |
string | not null |
distance |
integer | not null |
name |
string | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
creator_id
creator_id
referencesusers
Workouts
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
user_id |
integer | not null, indexed, foreign key |
start_time |
datetime | not null |
duration |
string | |
route_id |
integer | foreign key, indexed |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
user_id
- index on
route_id
user_id
referencesusers
route_id
referencesroutes
Friends
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
friend1_id |
integer | not null, indexed, foreign key |
friend2_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
friend2_id
- index on
[friend1_id, friend2_id], unique: true
friend2_id
referencesusers
friend1_id
referencesusers
comments
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
commentable_id |
integer | not null, indexed, foreign key |
user_id |
integer | not null, indexed, foreign key |
commentable_type |
string | not null |
body |
text | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
commentable_id
- index on
user_id
user_id
referencesusers
commentable_id
referencesroutes
orworkouts