Schema - Ajay-Vishwanath/SoundCloud2 GitHub Wiki

Database Schema

users

column name data type details
id integer not null, primary key
username string not null, indexed
email string not null, indexed, unique
location string 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

songs

column name data type details
id integer not null, primary key
title string not null, indexed
length integer not null
artist_id integer not null, indexed, foreign key
genre string not null
description string
audio binary not null
created_at datetime not null
updated_at datetime not null
  • artist_id references users
  • index on artist_id

comments

column name data type details
id integer not null, primary key
body string not null
user_id integer not null, indexed, foreign key
song_id integer not null, indexed, foreign key
parent_comment_id integer indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • song_id references songs
  • parent_comment_id self-references comments
  • index on user_id
  • index on song_id
  • index on parent_comment_id