Skip to content
Madeline Wilson edited this page Nov 1, 2021 · 27 revisions

Schema

users

column name data type details
id integer not null, primary key
email string not null, indexed, unique
username string not null, indexed, unique, limit: 15
name string
location string
about text
img_url text
artist_id integer indexed, foreign key
password_digest string not null
session_token string not null, indexed, unique
created_at datetime not null
updated_at datetime not null
  • index on email, unique: true
  • index on username, unique: true, limit: 15
  • index on name
  • index on session_token, unique:true
  • index on artist_id, allow_nil
  • name defaults to value of username unless otherwise specified

// Users will have a followers and followees many-to-many self-join association through the user.id and artist_id in the users table.

// Users will have a genres_liked association through the user_id in the genre_joins table.

// User show page will change based on the boolean value of the artist key. If true, the show page will include the user's songs and albums, otherwise, the show page will include the artists that the user is following, along with their preferred genres.

albums

column name data type details
id integer not null, primary key
title string not null.
artist_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • index on artist_id, not null
  • artist_id references users
  • has_many genres through genre_joins, album_id
  • has_many songs through songs, album_id

songs

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

genres

column name data type details
id integer not null, primary key
name string not null, indexed
created_at datetime not null
updated_at datetime not null
  • index on name, not null
  • has_many albums, through genre_joins, genre_id

genre_joins

column name data type details
id integer not null, primary key
album_id string not null, indexed, foreign key
genre_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • index on album_id, not null
  • index on genre_id, not null

Clone this wiki locally