Skip to content

Database Schema

Tommy Pham edited this page Apr 3, 2018 · 22 revisions

Database Schema

User

Column Name Data Type Details
ID Integer Not Null, Primary Key
username String Not Null, Indexed, Unique
password_digest String Not Null
session_token String Not Null, Indexed, Unique
email String Not Null, Indexed, Unique
profile_picture_url String
created_at Date Time Not Null
updated_at Date Time Not Null
  • Destroying a user will remove all blogs and follows associated with that user
    • Will transitively remove all likes associated with blogs as well

BlogPost

Column Name Data Type Details
ID Integer Not Null, Primary Key
author_id Integer Not Null, Foreign Key(refers to a User), Indexed
content_type String Not Null, Options(text, quote, image, audio, video)
title String
description Text
quote String
has_attached_file String
created_at Date Time Not Null
updated_at Date Time Not Null
  • has_attached_file content type will be validated via validates_attachment_content_type
  • Destroying a blog will remove all likes associated with that blog

Follow

Column Name Data Type Details
ID Integer Not Null, Primary Key
follower_id Integer Not Null, Foreign Key(refers to a User), Indexed
followee_id Integer Not Null, Foreign Key(refers to a user), Indexed
created_at Date Time Not Null
updated_at Date Time Not Null

Like

Column Name Data Type Details
ID Integer Not Null, Primary Key
liker_id Integer Not Null, Foreign Key(refers to a User), Indexed
liked_blog_id Integer Not Null, Foreign Key(refers to a Blog), Indexed
created_at Date Time Not Null
updated_at Date Time Not Null
Clone this wiki locally