Skip to content
yardenroee edited this page May 23, 2019 · 7 revisions

Database Schema

users

column name data type details
id integer not null, primary key
username string not null, indexed
password_digest string not null
session_token string not null, indexed, unique
img_url string
created_at datetime not null
updated_at datetime not null
  • index on username, unique: true
  • index on session_token, unique: true

albums

column name data type details
id integer not null, primary key
title string not null
artist_id integer not null, indexed, foreign_key
release_year integer
created_at datetime not null
updated_at datetime not null
  • index on artist_id

artists

column name data type details
id integer not null, primary key
name string not null
img_url string
created_at datetime not null
updated_at datetime not null

songs

column name data type details
id integer not null, primary key
album_id integer not null, foreign_key, indexed
artist_id integer not null, foreign_key, indexed
title string not null
length string not null
created_at datetime not null
updated_at datetime not null
  • index on album_id
  • index on artist_id

playlists

column name data type details
id integer not null, primary key
user_id integer not null, foreign_key, indexed
title string not null
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • index on user_id

playlist_songs

column name data type details
id integer not null, primary key
song_id integer not null, foreign_key, indexed
playlist_id integer not null, foreign_key, indexed
title string not null
created_at datetime not null
updated_at datetime not null
  • song_id references songs
  • playlist_id references playlists
  • index on song_id
  • index on playlist_id

follows

column name data type details
id integer not null, primary key
follower_id integer not null, foreign_key, indexed
followed_id integer not null, foreign_key, indexed
created_at datetime not null
updated_at datetime not null
  • followed_id references users
  • follower_id references users
  • follows belongs to a user
  • follower_id belongs to a user
Clone this wiki locally