Skip to content

Database Schema

zw301 edited this page Apr 12, 2018 · 36 revisions

Database Schema

user

Column Name Data Type Requires
id integer not null, primary key
email string not null, indexed, unique
first_name string not null
last_name string not null
phone_number string optional
password_digest string not null
session_token string not null
  • has_many reservations, (references reservation)
  • has_many favorites, (references favorite)
  • has_many restaurants, (through favorites)

restaurant

Column Name Data Type Requires
id integer not null, primary key
owner_id integer not null, foreign key
name string not null, indexed
address string not null
star integer not null
city string not null
state string not null
zipcode string not null
phone_number string not null
open_time string not null
close_time string not null
cuisine string not null
description string optional
logo string not null
  • has_many reservations, (references reservation)
  • has_many photos
  • has_many reviews
  • logo: ensure_logo method to set a default logo

reservation

Column Name Data Type Requires
id integer not null, primary key
user_id integer not null, foreign key
restaurant_id string not null, indexed
time string not null
date string not null
seats integer not null
  • has_one user, (references user)
  • has_one restaurant, (references restaurant)

favorite

Column Name Data Type Requires
id integer not null, primary key
user_id integer not null
restaurant_id integer not null

review

Column Name Data Type Requires
id integer not null, primary key
user_id integer not null, foreign key
restaurant_id integer not null
rating integer not null, include:[1,2,3,4,5]
comment text optional
  • has_one restaurant, (references restaurant) cutomer validation in model
Clone this wiki locally