schema - nooccarr/perfect-pixel GitHub Wiki

Database Schema

users

column_name data_type details
id integer not null, primary key
username string not null, indexed, unique
email string not null, indexed, unique
password_digest string not null
session_token datetime not null, indexed, unique
profile_url string
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

photos

column_name data_type details
id integer not null, primary key, indexed
title string not null, indexed
photographer_id integer not null, foreign key, indexed
image_url string
created_at datetime not null
updated_at datetime not null
  • photographer_id references users
  • index on title
  • index on photographer_id

follows

column_name data_type details
id integer not null, primary key, indexed
follower_id integer not null, foreign key, indexed, unique
following_id integer not null, foreign key, indexed, unique
created_at datetime not null
updated_at datetime not null
  • follower_id references users
  • following_id references users
  • index on [:follower_id, :following_id], unique: true

likes

column_name data_type details
id integer not null, primary key, indexed
liker_id integer not null, foreign key, unique, indexed
photo_id integer not null, foreign key, unique, indexed
created_at datetime not null
updated_at datetime not null
  • liker_id references users
  • photo_id references photos
  • index on [:liker_id, :photo_id], unique: true

comments

column_name data_type details
id integer not null, primary key, indexed
comment text not null
author_id integer not null, foreign key, indexed
photo_id integer not null, foreign key, indexed
parent_comment_id integer foreign key, indexed
image_url string
created_at datetime not null
updated_at datetime not null
  • author_id references users
  • photo_id references photos
  • parent_comment_id references comments
  • index on [:author_id, :photo_id, :parent_comment_id]