Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.
Jon Tran edited this page Nov 16, 2020 · 12 revisions

users

column name data type details
id integer not null, primary key
email string not null, indexed, unique
first_name string not null
last_name string not null
password_digest string not null
session_token string not null, indexed, unique
created_at datetime not null
updated_at datetime not null
  • index on email, unique: true
  • index on session_token, unique: true

videos

column name data type details
id integer not null, primary key
title string not null
description string not null
uploader_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • uploader_id references users
  • index on uploader_id

comments

column name data type details
id integer not null, primary key
body string not null
author_id integer not null, indexed, foreign key
video_id integer not null, indexed, foreign key
parent_comment_id integer indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • author_id references users
  • video_id references videos
  • parent_comment_id references comments
  • index on video_id
  • index on author_id
  • index on parent_comment_id

votes

column name data type details
id integer not null, primary key
is_voted? boolean not null
voter_id integer not null, indexed, foreign key
votable_id integer not null, indexed, foreign key
votable_type string not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • voter_id references users
  • votable_id references videos or comments
  • [:votable_id, :votable_type] polymorphic reference to videos or comments
  • index on [:votable_type, :votable_id, :voter_id], unique: true
  • index on votable_id
  • index on voter_id

views (bonus)

column name data type details
id integer not null, primary key
video_id integer not null, indexed, foreign key
viewer_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • video_id references videos
  • viewer_id references users (q: how to incorporate anonymous views?)
  • index on video_id
  • index on viewer_id

channels (bonus)

column name data type details
id integer not null, primary key
name string not null
description string
links string
user_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • channel_id references users
  • index on user_id

subscriptions (bonus)

column name data type details
id integer not null, primary key
subscriber_id integer not null, indexed, foreign key
channel_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • subscriber_id references users
  • channel_id references channel
  • index on [:channel_id, :subscriber_id], unique: true
  • index on subscriber_id
Clone this wiki locally