Skip to content

Database Schema

AlexDoes edited this page Dec 16, 2021 · 10 revisions

users

Column Name Data Type Details
id integer not null, primary key
email string not null, indexed, unique
password_digest string not null
first_name string not null
last_name string not null
session_token string not null, indexed, unique
bio text optional
created_at datetime not null
updated_at datetime not null
  • index on email, unique: true
  • index on session_token, unique: true

listings

Column Name Data Type Details
id integer not null, primary key
host_id integer not null, indexed, foreign_key
title string not null
description text not null
location string not null
guest_limit string not null
price integer not null
bedrooms integer not null
bathrooms integer not null
created_at datetime not null
updated_at datetime not null
  • index on host_id
  • host_id belongs_to host
  • host_id references users

reservations

Column Name Data Type Details
id integer not null, primary key
listing_id integer not null, indexed, foreign_key
guest_id integer not null, indexed, foreign_key
number_of_guests integer not null
check_in_date datetime not null
check_out_date datetime not null
created_at datetime not null
updated_at datetime not null
  • index on listing_id , guest_id
  • listing_id references listings
  • guest_id references users
  • listing_id belongs_to listing
  • guest_id belongs_to guest

reviews

Column Name Data Type Details
id integer not null, primary key
listing_id integer not null, indexed, foreign_key
guest_id integer not null, indexed, foreign_key
body text not null
rating integer not null
cleanliness integer not null
communication integer not null
check_in integer not null
accuracy integer not null
location integer not null
value integer not null
created_at datetime not null
updated_at datetime not null
  • index on listing_id , guest_id
  • listing_id references listings
  • guest_id references users
  • listing_id belongs_to listing
  • guest_id belongs_to guest

Clone this wiki locally