schema - Numbericons/LairBnB GitHub Wiki

Database Schema

users

column name data type details
id integer not null, primary key
username string not null, indexed, unique
email string not null, indexed, unique
host_description string not null
password_digest string not null
session_token string not null, indexed, unique
created_at datetime not null
updated_at datetime not null
  • index on username, unique: true
  • index on email, unique: true
  • index on session_token, unique: true

lairs

column name data type details
id integer not null, primary key
name string not null
description string not null
location string not null, indexed
lat float not null
lng float not null
city string indexed
country string not null, indexed
rate integer not null
max_guests integer not null, unique
type string not null, indexed
owner_id integer not null, indexed, foreign_key
torture_chamber boolean not null, default: false, indexed
minions boolean not null, default: false, indexed
wi_fi boolean not null, default: false, indexed
hero_detector boolean not null, default: false, indexed
pool boolean not null, default: false, indexed
cemetery boolean not null, default: false, indexed
created_at datetime not null
updated_at datetime not null
  • index on [:lat, :lng], unique: true
  • owner_id references users

bookings

column name data type details
id integer not null, primary key
lair_id integer not null, indexed, foreign_key
guest_id integer not null, indexed, foreign_key
num_guests integer not null
arrival_date date not null, indexed, unique
departure_date date not null, indexed, unique
created_at datetime not null
updated_at datetime not null
  • guest_id belongs_to users
  • lair_id belongs_to lairs

reviews

column name data type details
id integer not null, primary key
rating integer not null
body string not null
guest_id integer not null, indexed, foreign_key
lair_id integer not null, indexed, foreign_key
created_at datetime not null
updated_at datetime not null
  • guest_id belongs_to users
  • lair_id belongs_to lairs