Skip to content
grantpaulson6 edited this page Apr 28, 2019 · 13 revisions

Schema

User Profile

column name data type details
id integer not null, primary key
username text not null, unique, indexed
password_digest string not null
session_token string not null
first_name string not null
last_name string not null
email string not null, unique, indexed
gender string inclusion (male, female, other)
birthdate date
about text
created_at datetime not null
updated_at datetime not null
  • index on username, unique: true
  • index on session_token, unique: true
  • has_many bookings
  • has_many nests through bookings
  • has_many hosts through nests
  • has_many listings
  • has_many listing_bookings through listings
  • has_many customers through listing_bookings
  • has_many reviews, as reviewable

Listings

column name data type details
id integer not null, primary key
title string not null, unique, indexed
price float not null
description text not null
owner_id integer not null
max_guests integer not null
num_beds integer not null
num_bathrooms integer not null
street_address string not null
location string not null
zip_code integer not null
lat float not null
lon float not null
  • index on title, unique: true
  • has_many bookings
  • belongs_to owner
  • has_many reviews, as reviewable

Bookings

column name data type details
id integer not null, primary key
listing_id integer not null
nomad_id integer not null
start_date date not null
end_date date not null
  • belongs_to listings
  • belongs_to nomad

Reviews

column name data type details
id integer not null, primary key
author_id integer not null
reviewable_id integer not null
reviewable_type string not null
score integer not null, inclusion (0, 1, 2, 3, 4, 5)
review text not null, min characters
  • add_index reviews, [reviewable_type, reviewable_id], unique true
  • belongs_to author
  • belongs_to reviewable, polymorphic: true

Clone this wiki locally