Skip to content
StevenSuazo edited this page Nov 16, 2020 · 8 revisions

Users

Column Name Data Type Details
id integer not null, primary key
username string not null, unique, indexed
email string not null, unique, indexed
password_digest string not null
session_token string not null, unique, indexed
created_at datetime not null
updated_at datetime not null
  • index on email, unique: true
  • index on username, unique: true
  • index on session_token, unique: true

Photos

Column Name Data Type Details
id integer not null, primary key
title string not null
description text not null
user_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id foreign key references users
  • index on user_id
  • album_id foreign key references albums
  • index on album_id

Albums

Column Name Data Type Details
id integer not null, primary key
name string not null
description text not null
user_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id foreign key references users
  • index on user_id

Comments

Column Name Data Type Details
id integer not null, primary key
body text not null
author_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • author_id foreign key references user
  • index on author_id

Tags

Column Name Data Type Details
id integer not null, primary key
name string not null
created_at datetime not null
updated_at datetime not null

Joins Tables

Tags Join

Column Name Data Type Details
id integer not null, primary key
tag_id integer not null, indexed, foreign key
photo_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • tag_id foreign key references tags
  • index on tag_id
  • photo_id foreign key references photos
  • index on photo_id

Photo Album Join

Column Name Data Type Details
id integer not null, primary key
album_id integer not null, indexed, foreign key
photo_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • album_id foreign key references albums
  • index on album_id
  • photo_id foreign key references photos
  • index on photo_id

Clone this wiki locally