Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Database Schema

B Salinas edited this page Apr 26, 2021 · 12 revisions

SoundTrack Database Schema

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
session_token string not null, unique
created_at datetime not null
updated_at datetime not null
  • a user .hasMany songs
  • 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
title string(150) not null
user_id integer not null, foreignKey
album_id integer not null, foreignKey
created_at datetime not null
updated_at datetime not null
  • a song .belongsTo a user
  • a song .belongsTo an album
  • a song .hasMany likes
  • a song .hasMany comments
  • FOREIGN KEY user_id REFERENCES Users(id)
  • FOREIGN KEY album_id REFERENCES Album(id)

albums

Column Name Data Type Details
id integer serial, not null, primary key
title string(150) not null
user_id integer not null, foreignKey
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 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