Skip to content
Chris Kim edited this page Sep 19, 2017 · 8 revisions

Database Schema

users

Column Name Datatype Details
id integer not null, primary key
first_name string not null, indexed
last_name string not null, indexed
email string not null, indexed
password_digest string not null
session_token string not null
created_at datetime not null
updated_at datetime not null
image_url string not null
about text not null
  • has_many lodgings
  • has_many reviews
  • has_many bookings

lodgings

Column Name Datatype Details
id integer not null, primary key
created_at datetime not null
updated_at datetime not null
name string not null, indexed
address string not null
image_url string not null
owner_id integer not null, foreign key
about string not null
rate integer not null
room_type string not null
beds integer not null
bedrooms integer not null
guests integer not null
bathrooms integer not null
check_in string not null
amenities string array true, default []
  • belongs_to owner (owner_id refers to users)
  • has_many bookings
  • has_many reviews

Bookings

Column Name Datatype Details
id integer not null, primary key
created_at datetime not null
updated_at datetime not null
start_date date not null, not over end_date and cannot overlap with other dates
end_date date not null, not before start_date and cannot overlap with other dates
lodging_id integer not null, foreign key, indexed
booker_id integer not null, foreign key, indexed
  • belongs_to lodging
  • belongs_to booker (booker_id refers to users)

Reviews

Column Name Datatype Details
id integer not null, primary key
created_at datetime not null
updated_at datetime not null
title string not null
body text not null
lodging_id integer not null, foreign key
author_id integer not null, foreign key
  • belongs_to lodging
  • belongs_to author (author_id refers to users)

Clone this wiki locally