Skip to content
Jonathan Calixto edited this page Sep 18, 2020 · 6 revisions

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 string not null, 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

Photos

column name data type details
id integer not null, primary key
title string not null, indexed
description string optional
location string optional
gallery_id integer optional
photographer_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • index on title
  • index on photographer_id
  • photographer_id references users
  • gallery_id references galleries

Follows

column name data type details
id integer not null, primary key
photographer_id integer not null, indexed, foreign_key
follower_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • follower_id references users

Comments

column name data type details
id integer not null, primary key
body string not null
photo_id integer not null, indexed, foreign_key
commenter_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • commenter_id references users
  • photo_id references photos
  • index on photo_id
  • index on commenter_id

Likes

column name data type details
id integer not null, primary key
photo_id integer not null, indexed, foreign_key
liker_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • photo_id references photos
  • liker_id references users
  • index on photo_id
  • index on liker_id

Categories

column name data type details
id integer not null, primary key
category_name string not null
created_at datetime not null
updated_at datetime not null
  • photo_id references photos
  • index on photo_id

Photo_categories

column name data type details
id integer not null, primary key
photo_id integer not null, indexed, foreign key
category_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • photo_id references photos
  • category_id references categories
  • index on photo_id
  • index on category_id

Gallery_photos

column name data type details
id integer not null, primary key
photo_id integer not null, indexed, foreign key
gallery_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • photo_id references photos
  • gallery_id references galleries
  • index on photo_id
  • index on gallery_id

Galleries

column name data type details
id integer not null, primary key
title string not null, indexed, unique
owner_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • owner_id references users
  • index on title, unique: true
  • index on photo_id
  • index on owner_id
Clone this wiki locally