Skip to content
Timothy Chang edited this page Jan 27, 2023 · 28 revisions

Postgres Database Schema

users

column name data type details
id bigint not null, primary key
username string not null, indexed, unique
password_digest string not null
email string not null, indexed, unique
name string not null
birth_date 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
  • has_many songs
  • has_many likes
  • has_many playlists

songs

column name data type details
id bigint not null, primary key
album_id integer foreign key
artist_id integer not null, foreign key
title string not null, indexed
created_at datetime not null
updated_at datetime not null
  • index on title
  • artist_id references artists
  • album_id references albums
  • belongs_to users
  • belongs_to playlists
  • belongs_to artists
  • belongs_to albums

playlists

column name data type details
id bigint not null, primary key
author_id integer not null, indexed, foreign key
title string not null, indexed
public boolean not null
created_at datetime not null
updated_at datetime not null

likes

column name data type details
id bigint not null, primary key
liker_id integer not null, foreign key, indexed
media_id integer not null, foreign key, indexed
media_type string not null
created_at datetime not null
updated_at datetime not null

artists

column name data type details
id bigint not null, primary key
name string not null, indexed
description text not null
created_at datetime not null
updated_at datetime not null

albums

column name data type details
id bigint not null, primary key
title string not null, indexed
artist_id integer not null, foreign key, indexed
published_date string not null
created_at datetime not null
updated_at datetime not null

Clone this wiki locally