Database Schema - KevinNatera/Fumblr GitHub Wiki

users

column datatype properties
id integer null:false
username string null:false, index, unique
email string null:false, index, unique
password_digest string null:false
session_token string null:false, index, unique
created_at datetime null:false
updated_at datetime null:false
  • index on username, email, and session_token
  • foreign key: has_many posts
  • foreign key: has_many likes
  • foreign key: has_many comments

posts

column datatype properties
id integer null:false
author_id integer null:false, index
title string null:false
body string none
url string none
created_at datetime null:false,
updated_at datetime null:false
  • index on author_id
  • author_id references users
  • belongs_to author
  • foreign key: has_many likes
  • foreign key: has_many comments

comments

column datatype properties
id integer null:false
commenter_id integer null:false, index
post_id string null:false, index
body string null:false
created_at datetime null:false,
updated_at datetime null:false
  • index on commenter_id and post_id
  • commenter_id references users
  • post_id references posts
  • belongs_to commenter
  • belongs_to post

likes

column datatype properties
id integer null:false
liker_id integer null:false, index
post_id string null:false, index
created_at datetime null:false,
updated_at datetime null:false
  • index on liker_id and post_id
  • liker_id references users
  • post_id references posts
  • belongs_to liker
  • belongs_to post