Skip to content

Database Schema

junnac edited this page Nov 5, 2019 · 14 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, indexed, 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

cities

Column Name Data Type Details
id integer not null, primary key
name string not null, indexed, unique
state string not null, indexed
created_at datetime not null
updated_at datetime not null
  • index on name, unique: true
  • index on state

breweries

Column Name Data Type Details
id integer not null, primary key
name string not null, indexed, unique
lat float not null
lng float not null
address string not null
website string not null
description text
city_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • city_id references cities
  • index on name, unique: true

guides

Column Name Data Type Details
id integer not null, primary key
title string not null, indexed, unique
body text not null
city_id integer not null, indexed, unique, foreign key
created_at datetime not null
updated_at datetime not null
  • city_id references cities
  • index on title, unique: true

brewery_guides

Column Name Data Type Details
id integer not null, primary key
brewery_id integer not null, indexed, unique, foreign key
guide_id integer not null, indexed, unique, foreign key
created_at datetime not null
updated_at datetime not null
  • brewery_id references breweries
  • guide_id references guides

favorites

Column Name Data Type Details
id integer not null, primary key
user_id integer not null, indexed, unique, foreign key
brewery_id integer not null, indexed, unique, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • brewery_id references breweries
Clone this wiki locally