Schema
nramabad edited this page Dec 19, 2018
·
19 revisions
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
title |
string | not null |
year |
integer | not null |
genre |
string | not null |
artist_id |
integer | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
artist_id
references theartists
table - indexing on
artist_id
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
name |
string | not null |
bio |
text | |
created_at |
datetime | not null |
updated_at |
datetime | not null |
polymorphic joins table
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
user_id |
integer | not null, foreign key |
follow_id |
integer | not null, foreign key |
follow_type |
string | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
user_id
references theusers
table - indexing on
[:user_id, :follow_id], unique: true
-
followable_id
will reference either the songs, playlists, artists or albums tables based onfollow_type
- polymorphic association for followed artists and playlists
joins table
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
song_id |
integer | not null |
playlist_id |
integer | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
song_id
references thesongs
table -
playlist_id
references theplaylists
table - indexing on
playlist_id
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
title |
string | not null |
description |
text | |
user_id |
integer | not null, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
user_id
references theusers
table - indexing on
user_id
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
title |
string | not null |
duration |
integer | not null |
album_id |
integer | not null, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
album_id
references thealbums
table - indexing on
artist_id
- indexing on
album_id
joins table
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
follower_id |
integer | not null, foreign key |
followee_id |
integer | not null, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
follower_id
&follower_id
reference theusers
table - indexing on
followee_id
- indexing on
[:follower_id, :followee_id], unique: true
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
username |
string | not null, unique |
email |
string | not null, unique |
session_token |
string | not null |
password_digest |
string | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- indexing on
username, unique: true
- indexing on
email, unique: true
- indexing on
session_token