Schema - gradyzhu/smilr GitHub Wiki

Navigation

  1. Database Schema
  2. Joins Tables

Database Schema

user

Column Data Type Details
id integer not null, primary key, indexed
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

photos

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

albums

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

comments

Column Data Type Details
id integer not null, primary key, indexed
author_id integer not null, indexed, foreign key
photo_id integer not null, indexed, foreign key
body string not null
created_at datetime not null
updated_at datetime not null
  • author_id foreign key references users
  • photo_id foreign key references photos

tags

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

Joins Tables

album_photos

Column Data Type Details
id integer not null, primary key, indexed
album_id integer not null, indexed, foreign key
photo_id integer not null, indexed, foreign key
  • album_id references albums
  • photo_id references photos
  • [:album_id, :photo_id] unique: true

taggings

Column Data Type Details
id integer not null, primary key, indexed
tag_id integer not null, indexed, foreign key
photo_id integer not null, indexed, foreign key
  • tag_id foreign key tags
  • photo_id foreign key photos
  • [:tag_id, :photo_id] unique: true