-
Notifications
You must be signed in to change notification settings - Fork 0
Schema
Dan Lay edited this page Oct 10, 2022
·
7 revisions
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
username |
string | not null, indexed, unique |
email |
string | not null, indexed, unique |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
username, unique: true
- index on
email, unique: true
- index on
session_token, unique: true
- has_many
videos
- has_many
comments
- has_many
likes
- has_many
subscribers
BONUS
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
title |
string | not null |
description |
string | |
uploader_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 |
-
uploader_id
referencesusers
- index on
uploader_id
- index on
viewer_id
has_many comments
has_many views
belongs_to uploader
belongs_to viewer
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
body |
text | not null |
commenter_id |
integer | not null, indexed, foreign key |
video_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
commenter_id
referencesusers
-
video_id
referencesvideos
- index on
commenter_id
- index on
video_id
belongs_to commenter
belongs_to video
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
video_id |
integer | not null, indexed, foreign key |
feeler_id |
integer | not null, indexed, foreign key |
is_like |
boolean | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
feeler_id
referencesusers
-
video_id
referencesvideos
& index onfeeler_id
- index on
video_id
belongs_to feeler
belongs_to video
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
comment_id |
integer | not null, indexed, foreign key |
feeler_id |
integer | not null, indexed, foreign key |
is_like |
boolean | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
feeler_id
referencesusers
-
comment_id
referencescomments
& index onfeeler_id
- index on
commenter_id
belongs_to feeler
belongs to comment
- what to do about subscribers and streams?
- any missing / incorrect associations or indexes?