Basefloor Dev
Data models

Data Models

Database schema, entity relationships, and model definitions for Basefloor.

Data Models

This page documents the core database entities in the Basefloor HMS platform.

Entity Relationship Overview

HotelChain
  ├── User (staff)
  ├── Property
  │     ├── Room
  │     │     └── RoomAmenity → Amenity
  │     └── PropertyAmenity → Amenity
  └── Booking
        ├── Room
        └── Guest

HotelChain

The top-level tenant entity. All other models are scoped to a chain.

ColumnTypeDescription
idintegerPrimary key
namestringDisplay name of the chain
slugstringUnique subdomain identifier (e.g., khyber)
emailstringPrimary contact email
phonestringContact phone
created_atdatetime

User

Staff members who log in and use the system.

ColumnTypeDescription
idintegerPrimary key
hotel_chain_idintegerFK → HotelChain
emailstringUnique per chain
password_digeststringBCrypt hash
roleenumowner, manager, front_desk, housekeeping, read_only
first_namestring
last_namestring
activebooleanWhether the account can log in
last_sign_in_atdatetime

Property

A physical hotel location belonging to a chain.

ColumnTypeDescription
idintegerPrimary key
hotel_chain_idintegerFK → HotelChain
namestringProperty display name
addressstringStreet address
citystring
countrystringISO 3166-2 code
phonestring
emailstring
timezonestringIANA time zone identifier

Room

An individual guest room within a property.

ColumnTypeDescription
idintegerPrimary key
property_idintegerFK → Property
hotel_chain_idintegerFK → HotelChain (for scoping)
room_numberstringe.g., 101, Penthouse A
room_typestringe.g., standard, deluxe, suite
floorintegerFloor number
capacityintegerMax number of guests
base_ratedecimalNightly price
statusenumavailable, occupied, cleaning, maintenance

Guest

A guest who has stayed or is staying at any property in the chain.

ColumnTypeDescription
idintegerPrimary key
hotel_chain_idintegerFK → HotelChain
first_namestring
last_namestring
emailstring
phonestring
nationalitystringISO country code
date_of_birthdate
id_typestringpassport, national_id, driving_license
id_numberstringDocument number
notestextInternal staff notes
is_vipbooleanVIP flag

Booking

A reservation linking a guest to a room over a date range.

ColumnTypeDescription
idintegerPrimary key
hotel_chain_idintegerFK → HotelChain
property_idintegerFK → Property
room_idintegerFK → Room
guest_idintegerFK → Guest
check_in_datedate
check_out_datedate
statusenumconfirmed, checked_in, checked_out, cancelled, no_show
guests_countintegerNumber of guests in party
special_requeststextGuest requests at time of booking
total_amountdecimalCalculated total price
created_by_idintegerFK → User who created booking

Amenity

A feature available at a property or room level.

ColumnTypeDescription
idintegerPrimary key
namestringe.g., WiFi, Balcony, Pool
categorystringroom or property
iconstringIcon identifier for the UI

Scoping and Isolation

Every model that holds tenant data includes hotel_chain_id and a default_scope:

class Room < ApplicationRecord
  belongs_to :hotel_chain
  belongs_to :property

  default_scope { where(hotel_chain: Current.hotel_chain) }
end

Current.hotel_chain is set in ApplicationController from the subdomain on every request:

before_action :set_current_hotel_chain

def set_current_hotel_chain
  slug = request.subdomain
  Current.hotel_chain = HotelChain.find_by!(slug: slug)
end

On this page