Skip to content

Database Schema

trwong edited this page Nov 22, 2017 · 13 revisions

Database Schema

Users

column name data type details
id integer not null, primary key
first_name string not null, indexed
last_name string not null, indexed
email string not null, indexed, unique
profile_img_url string
cover_img_url string
password_digest string not null
session_token string not null, indexed, unique
created_at datetime not null
updated_at datetime not null

Posts

column name data type details
id integer not null, primary key
body text not null
author_id integer not null, indexed, foreign key
recipient_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • author_id references users who created the post
  • recipient_id references users who wall the post was written on

Comments

column name data type details
id integer not null, primary key
body text not null
author_id integer not null, indexed, foreign key
post_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • author_id references users who created the comment
  • post_id references posts which received the comment

Friends

column name data type details
id integer not null, primary key
requestor_id integer not null, indexed, foreign key
receiver_id integer not null, indexed, foreign key
status string not null, inclusion
  • requestor_id references users who sent a friend request
  • receiver_id references users who received a friend request
  • status will be validated for inclusion on nil, pending, accepted, denied

Clone this wiki locally