Skip to content
Ruiyu Wu edited this page Aug 28, 2019 · 29 revisions

users

column name data type details
id integer not null, primary key
email string not null
password_digest string not null
session_token string not null, indexed, unique
first_name string not null
last_name string not null
gender string not null
location string
workplace string
education string
current_city string
hometown string
bio text
birth_date datetime not null
created_at datetime not null
updated_at datetime not null
  • add_index to email, unique: true
  • add_index to session_token, unique: true

posts

column name data type details
id integer not null, primary key
body text
author_id integer not null, indexed
user_id integer not null, indexed
created_at datetime not null
updated_at datetime not null
  • add_index to author_id
  • add_index to user_id
  • author_id refers to users (who authored this post)
  • user_id refers to users (to whom the post belongs)
  • posts will just be validated on the front-end for whether or not it needs a body (depending on if it has a picture)

comments

column name data type details
id integer not null, primary key
body text
author_id integer not null, indexed
post_id integer not null, indexed
parent_comment_id integer optional, indexed
created_at datetime not null
updated_at datetime not null
  • add_index to author_id
  • add_index to post_id
  • add_index to parent_comment_id
  • author_id refers to users
  • post_id refers to posts

friendships

column name data type details
id integer not null, primary key
requester_id integer not null, indexed
requested_friend_id integer not null, indexed
status string not null, default: "pending"
created_at datetime not null
updated_at datetime not null
  • add_index to requester_id
  • add_index to requested_friend_id
  • add_index to [requester_id, requested_friend_id], unique: true
  • requester_id refers to users
  • requested_friend_id refers to users

likes

column name data type details
id integer not null, primary key
user_id integer not null, indexed
likeable_id integer not null, indexed
likeable_type string not null
created_at datetime not null
updated_at datetime not null
  • add_index to user_id
  • add_index to likeable_id

tags

column name data type details
id integer not null, primary key
post_id integer not null, indexed
user_id integer not null, indexed
created_at datetime not null
updated_at datetime not null
  • add_index to user_id
  • add_index to post_id

BONUSES

workplaces

column name data type details
id integer not null, primary key
name string not null
created_at datetime not null
updated_at datetime not null

educations

column name data type details
id integer not null, primary key
name string not null
created_at datetime not null
updated_at datetime not null

locations

column name data type details
id integer not null, primary key
name string not null
created_at datetime not null
updated_at datetime not null
Clone this wiki locally