Skip to content
HotelMind AI

Data

Warehouse Schema

Dimensions, facts, and marts.

Source: hotelmind-data/docs/warehouse_schema.md

HotelMind AI — Warehouse Schema Reference

Star Schema Entity Relationship (Text)

                              dim_date
                           ┌──────────────┐
                           │ date_key (PK)│
                           │ date         │
                           │ year         │
                           │ month        │
                           │ quarter      │
                           │ week_of_year │
                           │ day_name     │
                           │ is_weekend   │
                           │ is_holiday   │
                           └──────┬───────┘
                                  │ check_in/out_date_key, order_date_key, shift_date_key
            ┌─────────────────────┼────────────────────────┐
            ▼                     ▼                        ▼
    fact_booking        fact_restaurant_sale    fact_staff_attendance
    ┌─────────────┐     ┌─────────────────┐    ┌──────────────────┐
    │surrogate_key│     │surrogate_key    │    │surrogate_key     │
    │reservation_id│    │order_item_id    │    │attendance_id     │
    │room_key (FK)│     │menu_item_key(FK)│    │employee_key (FK) │
    │branch_key(FK│     │branch_key (FK)  │    │branch_key (FK)   │
    │hotel_key(FK)│     │hotel_key (FK)   │    │hotel_key (FK)    │
    │guest_key(FK)│     │order_date_key(FK│    │shift_date_key(FK)│
    │check_in_dk  │     │order_id         │    │scheduled_hours   │
    │check_out_dk │     │order_status     │    │actual_hours      │
    │nights       │     │quantity         │    │variance_hours    │
    │adults       │     │unit_price       │    │attendance_status │
    │total_amount │     │subtotal         │    └──────────────────┘
    │paid_amount  │     │price_variance   │
    │avg_daily_rate│    └─────────────────┘
    │is_terminal  │
    └─────────────┘
            │                                    fact_occupancy_daily
            │                                   ┌──────────────────────┐
            │                                   │surrogate_key         │
            │                                   │branch_key (FK)       │
            │                                   │hotel_key (FK)        │
            │                                   │date_key (FK)         │
            │                                   │total_rooms           │
            │                                   │occupied_rooms        │
            │                                   │available_rooms       │
            │                                   │occupancy_pct         │
            │                                   └──────────────────────┘

   ┌────────┴─────────────────────────────────────┐
   ▼         ▼           ▼          ▼             ▼
dim_room  dim_branch  dim_hotel  dim_guest  dim_employee  dim_menu_item

Dimension Tables

dim_date

ColumnTypeDescription
date_keyINTEGERYYYYMMDD (PK)
dateDATECalendar date
yearINTEGERCalendar year
quarterINTEGER1–4
monthINTEGER1–12
month_nameVARCHAR'January' etc
week_of_yearINTEGERISO week number
day_of_monthINTEGER1–31
day_of_weekINTEGER0=Sunday
day_nameVARCHAR'Monday' etc
is_weekendBOOLEANTrue for Sat/Sun
is_holidayBOOLEANPlaceholder, always false in Phase 3
fiscal_yearINTEGERSame as calendar year
first_day_of_monthDATEFor MTD filters
last_day_of_monthDATEFor period-end labels
first_day_of_yearDATEFor YTD filters

dim_hotel

ColumnTypeDescription
hotel_keyVARCHARSurrogate PK (MD5 hash)
hotel_idUUIDNatural key from operational DB
hotel_nameVARCHARHotel name
star_ratingINTEGER1–5
cityVARCHARCity
countryVARCHARCountry
addressTEXTFull address
is_activeBOOLEANSoft-delete flag

dim_branch

ColumnTypeDescription
branch_keyVARCHARSurrogate PK
branch_idUUIDNatural key
hotel_keyVARCHARFK → dim_hotel
hotel_idUUIDDenormalised hotel UUID
hotel_nameVARCHARDenormalised hotel name
branch_nameVARCHARBranch name
cityVARCHARBranch city (falls back to hotel city)
countryVARCHARFrom parent hotel
is_main_branchBOOLEAN

dim_room

ColumnTypeDescription
room_keyVARCHARSurrogate PK
room_idUUIDNatural key
branch_keyVARCHARFK → dim_branch
hotel_nameVARCHARDenormalised
branch_nameVARCHARDenormalised
floor_numberINTEGERFloor level
room_numberVARCHARe.g., "301"
room_type_nameVARCHARSTANDARD, DELUXE, SUITE, PRESIDENTIAL
base_priceNUMERIC(10,2)Daily rate
max_occupancyINTEGERGuest capacity
amenity_namesTEXTPipe-delimited: "WiFi | AC | TV"
amenity_countINTEGERCount of amenities
current_statusVARCHARAVAILABLE, OCCUPIED, MAINTENANCE, CLEANING
is_activeBOOLEAN

dim_guest

ColumnTypeDescription
guest_keyVARCHARSurrogate PK
guest_idUUIDNatural key
first_nameVARCHAR
last_nameVARCHAR
full_nameVARCHARfirst + last
emailVARCHARLowercased
phoneVARCHAR
nationalityVARCHAR
lifetime_bookingsINTEGERComputed at dbt run time
lifetime_spendNUMERIC(12,2)Total revenue from non-terminal reservations
first_stay_dateDATEEarliest check-in
last_stay_dateDATEMost recent check-in

dim_employee

ColumnTypeDescription
employee_keyVARCHARSurrogate PK
employee_idUUIDNatural key
branch_keyVARCHARFK → dim_branch
department_idUUIDNatural FK
department_nameVARCHARDenormalised
full_nameVARCHAR
emailVARCHAR
roleVARCHARJob title
hire_dateDATE
tenure_yearsINTEGERApproximate years
is_activeBOOLEAN

dim_menu_item

ColumnTypeDescription
menu_item_keyVARCHARSurrogate PK
menu_item_idUUIDNatural key
branch_keyVARCHARFK → dim_branch
category_nameVARCHARDenormalised food category
item_nameVARCHARDish name
current_priceNUMERIC(10,2)Current menu price
is_availableBOOLEAN

Fact Tables

fact_booking

Grain: One row per reservation Incremental: Yes (on updated_at)

ColumnTypeDescription
surrogate_keyVARCHARPK (hash of reservation_id)
reservation_idUUIDDegenerate dimension
reservation_statusVARCHARPENDING, CONFIRMED, etc
room_keyVARCHARFK → dim_room
branch_keyVARCHARFK → dim_branch
hotel_keyVARCHARFK → dim_hotel
guest_keyVARCHARFK → dim_guest
check_in_date_keyINTEGERFK → dim_date
check_out_date_keyINTEGERFK → dim_date
nightsINTEGERcheck_out - check_in
adultsINTEGER
childrenINTEGER
total_amountNUMERIC(10,2)Booking total
paid_amountNUMERIC(10,2)Amount received
outstanding_amountNUMERIC(10,2)total - paid
avg_daily_rateNUMERIC(10,2)total / nights
is_terminalBOOLEANCANCELLED or NO_SHOW
is_completedBOOLEANCHECKED_OUT

fact_restaurant_sale

Grain: One row per order line item Incremental: Yes (on updated_at)

ColumnTypeDescription
surrogate_keyVARCHARPK (hash of order_item_id)
order_item_idUUIDDegenerate dimension
order_idUUIDDegenerate dimension
order_statusVARCHAROPEN, CLOSED, CANCELLED
menu_item_keyVARCHARFK → dim_menu_item
branch_keyVARCHARFK → dim_branch
hotel_keyVARCHARFK → dim_hotel
order_date_keyINTEGERFK → dim_date
quantityINTEGERItems ordered
unit_priceNUMERIC(10,2)Price at time of order
subtotalNUMERIC(10,2)quantity × unit_price
price_varianceNUMERIC(10,2)unit_price vs current menu price

fact_occupancy_daily

Grain: One row per branch per calendar date Materialization: Table (full rebuild — O(branches × 730 days))

ColumnTypeDescription
surrogate_keyVARCHARPK (hash of branch_id + date_key)
branch_keyVARCHARFK → dim_branch
hotel_keyVARCHARFK → dim_hotel
date_keyINTEGERFK → dim_date
occupancy_dateDATE
total_roomsINTEGERActive rooms in branch
occupied_roomsINTEGERRooms with active reservation that day
available_roomsINTEGERtotal - occupied
occupancy_pctNUMERIC(5,2)occupied / total × 100

fact_staff_attendance

Grain: One row per attendance record Incremental: Yes (on updated_at)

ColumnTypeDescription
surrogate_keyVARCHARPK
attendance_idUUIDDegenerate dimension
attendance_statusVARCHARPRESENT, ABSENT, LATE, HALF_DAY
employee_keyVARCHARFK → dim_employee
branch_keyVARCHARFK → dim_branch
hotel_keyVARCHARFK → dim_hotel
shift_date_keyINTEGERFK → dim_date
scheduled_hoursNUMERIC(5,2)From schedule
actual_hoursNUMERIC(5,2)From attendance clock times
variance_hoursNUMERIC(5,2)actual - scheduled
is_presentBOOLEAN
is_lateBOOLEAN

Mart Tables

mart_revenue_daily

Grain: branch_id × date | For: BI dashboards, Phase 4 revenue forecasting

Key columns: total_revenue, room_revenue, fb_revenue, avg_daily_rate, revpar, occupancy_pct, revenue_7day_avg, revenue_mtd, revenue_ytd

mart_occupancy_daily

Grain: branch_id × date | For: Phase 4 occupancy forecasting ML model

Key columns: occupancy_pct, occupancy_7day_avg, occupancy_30day_avg, occupancy_pct_lag_7d, occupancy_pct_lag_365d, occupancy_mtd_avg

mart_restaurant_daily

Grain: branch_id × date | For: Phase 4 restaurant demand forecasting

Key columns: total_orders, items_sold, total_revenue, avg_order_value, breakfast_revenue, lunch_revenue, dinner_revenue, revenue_7day_avg

mart_staff_daily

Grain: branch_id × department_id × date | For: Phase 4 staff optimization

Key columns: scheduled_employees, present_employees, attendance_rate_pct, total_actual_hours, hours_utilisation_pct