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

Schema

Profile

column name data type details
username text not null, unique, indexed
password_digest text not null
session_token text not null
first_name text not null
last_name text not null
email text
gender text inclusion (male, female, other)
birthdate date
about text

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

Listings

column name data type details
title text not null, unique, indexed
price float not null
description text
owner_id integer not null
max_guests integer
num_beds integer
num_bathrooms integer
street_address text
city text
zip_code integer
lat float
lon float

has_many bookings
belongs_to owner

Bookings

column name data type details
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 (of listings)

column name data type details
author_id integer not null
listing_id integer not null
score integer not null, inclusion (0 , 1, 2, 3, 4, 5)
review text not null, min characters

combo index author_id/listing_id, unique true
belongs_to author
belongs_to listing

Reviews (of users)

column name data type details
author_id integer not null
nomad_id integer not null
score integer not null, inclusion (0 , 1, 2, 3, 4, 5)
review text not null, min characters

combo index author_id/nomad_id, unique true
belongs_to author
belongs_to nomad

Clone this wiki locally