Schema - n8gallagher/fotopx GitHub Wiki

Postgres Database Schema

users

column name data type details
id integer primary key
username string not null, unique, indexed
session_token string not null, indexed, unique
password_digest string not null
created_at datetime not null
updated_at datetime not null
  • index on username, unique: true
  • index on session_token, unique: true

photos

column name data type details
id integer primary key
title string not null, unique, indexed
user_id integer foreign key, not null, indexed
description text not null
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • index on user_id

likes

column name data type details
id integer primary key
user_id integer foreign key, not null, indexed
photo_id integer foreign key, not null, indexed
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • photo_id references photos
  • index on [:photo_id, :user_id], unique: true

follows

column name data type details
id integer primary key
follower_id integer foreign key, not null, indexed
followee_id integer foreign key, not null, indexed
created_at datetime not null
updated_at datetime not null
  • follower_id references users
  • followee_id references users
  • index on [:follower_id, :followee_id], unique: true