Repository navigation
Schema
Irene Martinez edited this page Mar 7, 2024
·
17 revisions
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
username |
string | not null, indexed, unique |
email |
string | not null, indexed, unique |
birthday |
date | 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
username, unique: true - index on
email, unique: true - index on
session_token, unique: true -
(future association tohas_many playlistsplaylistswhen users can be deleted) -
(in the future, the queue would be persisted to the database to be resumed)has_many queued songs -
(stretch feature), referencing songs throughhas_many liked_songslikings
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
title |
string | not null, indexed |
album_id |
integer | not null, indexed, foreign key |
tracknum |
integer | not null |
duration |
integer | not null |
audio_url |
string | not null |
album_image_url |
string | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
durationis song length in seconds -
album_idreferencesalbums - index on
title - index on
:album_id, :title, unique:true belongs_to album-
has_one song_artistreferencingartiststhroughalbum -
has_many collab_artistsreferencingartiststhroughcollab_artist -
has_many playlistedsreferencingplaylisted -
has_many playlistsreferencingplaylistthroughplaylisted -
(bonus/stretch feature)has_one like
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
title |
string | not null, indexed |
artist_id |
integer | not null, indexed, foreign key |
year |
integer | not null |
genre |
string | not null |
photo_url |
string | indexed |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
artist_idreferencesartists - index on
title - index on
[:artist_id, :title], unique: true - index on
photo_url -
belongs_to album_artist, referencingartists -
has_many tracks, referencingsongs
| Column Name | Data Type | Details |
|---|---|---|
id |
integer | not null, primary key |
name |
string | not null, indexed |
photo_url |
string | indexed |
num_listeners |
string | indexed |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
name - index on
photo_url -
has_many albums, referencingalbums -
has_many collabs, referencingcollabs -
has_many collab_songs, referencingsongsthroughcollabs
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
title |
string | not null, indexed |
description |
string | not null |
user_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
user_idreferencesusers - index on
user_id - index on
updated_at -
future association tobelongs_to useruserswhen users can be deleted -
has_manyplaylistedreferencingplaylisted`, which are destroy-dependent -
has_many playlist_songsreferencingsongsthroughplaylisted
This is a joins table to allow multiple collaboration artists to be associated with a song.
| column name | data type | details |
|---|---|---|
song_id |
integer | not null, foreign key |
artist_id |
integer | not null, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
song_idreferencessongs -
artist_idreferencesartists - index on
[:song_id, :artist_id], unique: true -
belongs_to collabreferencingsongs -
belongs_to collab_artistreferencingartists
This is a joins table to allow songs to be added to many playlists multiple times.
| Column Name | Data Type | Details |
|---|---|---|
id |
integer | not null, primary key |
song_id |
integer | not null, indexed, foreign key |
playlist_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
song_idreferencessongs -
playlist_idreferencesplaylists - index on
playlist_id - index on
song_id belongs_to songbelongs_to playlist
This would be a joins table allowing songs to be liked (once) by multiple users.
| Column Name | Data Type | Details |
|---|---|---|
id |
integer | not null, primary key |
song_id |
integer | not null, indexed, foreign key |
user_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
song_idreferencessongs -
user_idreferencesusers - index on
[:song_id, :user_id], unique: true belongs_to songbelongs_to user
This would be a joins table allowing songs to be saved in the queues of multiple users.
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
song_id |
integer | not null, indexed, foreign key |
user_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
song_idreferencessongs -
user_idreferencesusers - index on
song_id - index on
user_id belongs_to songbelongs_to user