A channel manager is mostly a calendar. For every room type and every rate plan, for every night for a year or more, it holds a number and knows whether the booking sites have it. Get the tables right and most features become simple. Get them wrong and you spend years writing repair scripts. This part sets out the tables we use, in plain terms, with the columns that mattered most.
Three kinds of tables
The tables fall into three groups. They change at very different speeds, so keep them apart.
| Group | Tables | How often they change |
|---|---|---|
| Setup | Property, room types, rate plans, links to each booking site | A few times a year |
| Calendar | Prices, room counts and rules, one row per night | Every day |
| Work | Bookings, incoming booking versions, change notes, the work queue, the send log | Every second |
Setup tables
Property. One row per hotel. Keep its time zone and its currency here, because almost everything else depends on them.
Room types. One row per room type: name, the number of physical rooms, and the maximum number of guests. Part 5 explained why that maximum matters.
Rate plans. One row per plan: its room type, meal plan and number of guests. If the plan follows a parent, store the parent and the rule (a percentage and an amount), as part 6 explained. Store a default price too, so a new night always has a price someone chose.
Links to booking sites. One row per pair: your plan or room type, and the site's id for it. Add a unique rule so one site rate can only have one live link. Two plans pointing at one site rate overwrite each other's prices.
Calendar tables: one row per thing per night
This is the heart of the schema. Three tables, each with a unique key on the thing and the night:
- Prices: one row per rate plan per night.
- Room counts: one row per room type per night.
- Rules: one row per rate plan per night, for stop sell, closed to arrival, closed to departure, and the stay lengths. Part 3 explained each one.
A hotel with 3 room types and 12 rate plans, over a 500-day window, keeps about 1,500 room count rows and 6,000 price rows. That is small for any database. Do not be tempted to save rows by storing ranges. Ranges make every single-night change a split, and splits are where bugs hide.
The columns that saved us most:
| Column | Why |
|---|---|
| The value, such as the price or the count | Obvious |
| Where it came from: typed by a person, the pricing engine, the plan's default | So a person's choice is never overwritten by an automatic one |
| Who typed it, and why | So staff can answer "who closed this night?" |
| Until when it holds | So a hand-typed number ends on its own instead of living forever |
| The last value sent | So you send only what changed |
| What the channel manager was last seen holding, and when | Because sent is not the same as held |
Money and dates
Two rules, applied everywhere:
- Money is a whole number of the smallest unit. 4,200.50 rupees is stored as 420050 paise. No floating point, ever.
- A stay covers check-in up to, but not including, check-out. A booking from 10 to 12 March holds the nights of 10 and 11 March. Checkout morning is not a night.
Worked example
One booking in the tables
In this example, a guest books a Deluxe room from 10 to 12 March through a booking site.
- The incoming version is stored first, with its own id.
- A booking row stores the site's reservation number, and a booking room row stores Deluxe, 10 March to 12 March.
- A change note records "Deluxe, 10 to 12 March changed", in the same database step as the booking.
- The work queue gets two rows: Deluxe on 10 March and Deluxe on 11 March.
- The sender works out the new counts, sends them, writes the send log and deletes the two queue rows.
Work tables
Incoming booking versions. Every version a booking site sends is stored before anything else, with its own id as a unique key. A repeat is recognised and ignored. A change that arrives before its booking waits here. Part 7 explained the order.
Bookings and booking rooms. Keep the booking site's reservation number, the source, and who collected the payment. Lock the source and reservation number once the booking arrives: staff should never change them.
Change notes. One row per event that changed a room count: a booking, a cancel, a block, a typed number. It records who did it, what nights it touched, and whether it was sent. This is the outbox part 8 described.
The work queue. One row per room type and night that must be sent, keyed on exactly that. Ten changes to the same night in one second become one row. The sender deletes a row after a good send.
The send log and the sync state. One row for each value that changed, with what it was before and after. And one row per property: last good send, failures in a row, and since when it has been out of sync. Staff read these when they ask "did it go?"
- Setup, calendar and work tables are separate.
- Each calendar table has a unique key on the thing and the night.
- Nights are calendar days in the hotel's time zone.
- Money is a whole number of the smallest unit.
- Each hand-typed value records who, why and until when.
- "Sent" and "held by the channel manager" are separate columns.
- Incoming booking versions are stored, by their own id, before processing.
- The work queue is keyed on room type and night, so bursts collapse.
One row per thing per night. Everything else gets simpler from there.
What to check in your own system
- You can answer "who changed this night, and why?" for any price or room count.
- You can show, for any night, what you sent and what the channel manager holds.
- A booking cannot land on the wrong night when a server runs in another time zone.
- A repeated booking version changes nothing.
- The work queue empties on its own after a burst of bookings.
Part 11 looks at the screens built on top of these tables. Our channel manager is built on this schema.
