Skip to content
yangel20 edited this page Nov 16, 2020 · 6 revisions

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 string not null, indexed, unique
created_at datetime not null
updated_at datetime not null
  • index username, unique: true
  • index email, unique: true
  • index 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 not null not null, indexed
created_at datetime not null
updated_at datetime not null
  • user_id reference users
  • index on user_id

Albums

Column name Data Type Details
id integer not null, primary key
title string not null
user_id string not null, indexed
created_at datetime not null
updated_at datetime not null
  • user_id reference users
  • index on user_id

Comments

Column name Data Type Details
id integer not null, primary key
body string not null
user_id integer not null, indexed
photo_id integer not null, indexed
created_at datetime not null
updated_at datetime not null
  • user_id reference users
  • photo_id reference photos
  • index on user_id
  • index on photo_id

Photo_albums

Column name Data Type Details
id integer not null, primary key
album_id integer not null, indexed
photo_id integer not null, indexed
created_at datetime not null
updated_at datetime not null
  • index on album_id
  • index on photo_id

Tags

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

tagged_photo

Column name Data Type Details
id integer not null, primary key
tag_id integer not null, indexed
photo_id integer not null, indexed
created_at datetime not null
updated_at datetime not null
  • tag_id reference tags
  • photo_id reference photos

Clone this wiki locally