Skip to content

Database Schema

B Salinas edited this page Jun 2, 2021 · 12 revisions

users

Column Name Data Type Details
id integer serial, not null, primary key
username string(50) not null, unique
hashedPassword string.binary not null
profilePic string(255) not null
created_at datetime not null
updated_at datetime not null
  • a user .hasMany albums
  • a user .hasMany likes
  • a user .hasMany comments
  • a user .hasMany follows

songs

Column Name Data Type Details
id integer serial, not null, primary key
album_id integer not null, foreignKey
song_title string(150) not null
image_url varchar not null, foreignKey
audio_url varchar not null,
created_at datetime not null
updated_at datetime not null
  • a song .belongsTo an album
  • a song .hasMany likes
  • a song .hasMany comments
  • FOREIGN KEY album_id REFERENCES Album(id)
  • FOREIGN KEY image_url REFERENCES Album(image_url)

albums

Column Name Data Type Details
id integer serial, not null, primary key
user_id integer not null, foreignKey
album_title string(150) not null
image_url string(250) not null,
created_at datetime not null
updated_at datetime not null
  • an album .hasMany songs
  • an album .belongsTo a user
  • FOREIGN KEY user_id REFERENCES Users(id)

likes

Column Name Data Type Details
id integer serial, not null, primary key
user_id integer not null
song_id integer not null
created_at datetime not null
updated_at datetime not null
  • a like .belongsTo a user
  • a like .belongsTo a song
  • FOREIGN KEY user_id REFERENCES Users(id)
  • FOREIGN KEY song_id REFERENCES Songs(id)

comments

Column Name Data Type Details
id integer serial, not null, primary key
user_id integer not null, foreignKey
song_id integer not null, foreignKey
content string(250) not null
created_at datetime not null
updated_at datetime not null
  • a comment .belongsTo a user
  • a comment .belongsTo a song
  • FOREIGN KEY user_id REFERENCES Users(id)
  • FOREIGN KEY song REFERENCES Songs(id)

follows

Column Name Data Type Details
id integer serial, not null, primary key
user_id integer not null, foreignKey
followed_user_id integer not null, foreignKey
created_at datetime not null
updated_at datetime not null
  • a user .hasMany followed_user_id
  • a followed_user_id .belongsTo a user
  • FOREIGN KEY user_id REFERENCES Users(id)
  • FOREIGN KEY followed_user_id REFERENCES Users(id)

Check out the developer behind this project!

Clone this wiki locally