Schema - samwalker191/Tubular GitHub Wiki
Database Schema
users
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
username |
string | not null, unique, indexed |
email |
string | not null, unique, indexed |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
created_at |
datetime | not null |
updated_at |
datetime | not null |
videos
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
title |
string | not null, indexed |
owner_id |
integer | not null, indexed, foreign key |
views |
integer | not null, default: 0 |
description |
text | not null, default: 'No description' |
created_at |
datetime | not null |
updated_at |
datetime | not null |
owner_id
referencesusers
likes
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
liked |
boolean | not null |
user_id |
integer | not null, indexed, foreign key |
likeable_id |
integer | not null, indexed |
likeable_type |
string | not null, indexed |
created_at |
datetime | not null |
updated_at |
datetime | not null |
likes
will reference bothcomments
andvideos
vialikeable_id
andlikeable_type
- index on
[user_id, likeable_id, likeable_type], unique: true
comments
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
body |
string | not null |
user_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 |
user_id
referencesusers
video_id
referencesvideos
channels
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
owner_id |
integer | not null, indexed, foreign key, unique |
title |
string | not null, indexed |
description |
text | not null, default: 'No description' |
created_at |
datetime | not null |
updated_at |
datetime | not null |
owner_id
referencesusers
subscriptions
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
subscriber_id |
integer | not null, indexed, foreign key, unique |
channel_id |
integer | not null, indexed, foreign key, unique |
created_at |
datetime | not null |
updated_at |
datetime | not null |
subscriber_id
referencesusers
channel_id
referenceschannels
- index on
[:subscriber_id, :channel_id], unique: true
playlists
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
user_id |
integer | indexed, foreign key |
title |
string | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
user_id
referencesusers
playlistings
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
playlist_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 |
playlist_id
referencesplaylists
video_id
referencesvideos