Schema - misshenyc/Wedio GitHub Wiki
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 |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
created_at |
datetime | not null |
update_at |
datetime | not null |
user has_many videos:
- foreign_key: creator_id;
- table: videos;
user has_many comments:
- foreign_key: commentor_id;
- table: comments;
user has_many plays:
- foreign_key: viewer_id;
- table: users
user has_one channel:
- foreign_key: owner_id;
- table: channels;
videos
Column name | Data type | Details |
---|---|---|
id |
integer | not null, primary key |
title |
string | not null |
description |
string | not null |
creator_id |
integer | not null, indexed, unique, foreign_key |
created_at |
datetime | not null |
update_at |
datetime | not null |
video belongs_to a creator:
- foreign_key: creator_id;
- table: users;
video has_many comments:
- foreign_key: video_id;
- table: comments;
video has_many likes:
- :as => :likable
video has_many plays:
- foreign_key: video_id;
- table: video_plays;
video_plays
Column name | Data type | Details |
---|---|---|
id |
integer | not null, primary key |
viewer_id |
integer | not null, index, foreign_key |
video_id |
integer | not null, index, foreign_key |
created_at |
datetime | not null |
update_at |
datetime | not null |
video_play belongs to viewer:
- foreign_key: viewer_id;
- table: users
video_play belongs to a video:
- foreign_key: video_id;
- table: videos
comments
Column name | Data type | Details |
---|---|---|
id |
integer | not null, primary key |
body |
string | not null |
commenter_id |
integer | not null, indexed, unique |
video_id |
integer | not null, indexed, unique, foreign key |
created_at |
datetime | not null |
update_at |
datetime | not null |
comment belongs_to a commentor:
- foreign_key: commentor_id;
- table: users
comment belongs_to a video:
- foreign_key: video_id;
- table: videos
comment has_many likes:
- :as => :likable
likes
polymorphic associations
Column name | Data type | Details |
---|---|---|
id |
integer | not null, primary key |
if_like |
boolean | not null, default: false |
if_dislike |
boolean | not null, default: false |
likeable_id |
integer | not null |
likeable_type |
string | not null |
created_at |
datetime | not null |
update_at |
datetime | not null |
channels
note: bonus
Column name | Data type | Details |
---|---|---|
id |
integer | not null, primary key |
channel_name |
string | not null |
owner_id |
integer | not null, indexed, foreign_key |
created_at |
datetime | not null |
update_at |
datetime | not null |
channel has_one: owner *foreign_key: owner_id; *table: users
channel has_many subscriptions:
- foreign_key: subscriber_id;
- table: subscriptions
subscriptions
note: bonus
Column name | Data type | Details |
---|---|---|
id |
integer | not null, primary key |
channel_id |
integer | not null, indexed, unique, foreign key(refers to the channels table) |
subscriber_id |
integer | not null, indexed, unique, foreign key(refers to the users table) |
created_at |
datetime | not null |
update_at |
datetime | not null |
subscription belongs_to channel;
- foreign_key: channel_id;
- table: channels;
subscription belongs_to user;
- foreign_key: subscriber_id;
- table: users;