The short answer
- Put the booking in the middle: it joins a customer, a service and a member of staff.
- Write each rule as a question, then check the tables can answer it.
- Keep facts that must not change, such as the price paid, on the booking itself.
A finished example
This is what the Bookings database template can look like once it is filled in. This one is for a hair salon taking bookings online.
Read the example as words
- On the board
- Customer: id, number, main ID; name, text; email, text; phone, text
- Booking: id, number, main ID; customer_id, number, links to another table; service_id, number, links to another table; staff_id, number, links to another table; starts, date; status, text; price_paid, money
- Service: id, number, main ID; name, text; minutes, number; price, money
- Staff member: id, number, main ID; name, text; works_from, date
- Rules to agree
- One booking, one service. A cut and colour is two bookings
- A booking can wait for a stylist to be chosen
- Keep the price paid on the booking
- How the boxes are joined
- Customer makes Booking, one to many
- Service is booked as Booking, one to many
- Staff member takes Booking, one or none to many
What a bookings system has to remember
A salon, a clinic, a tutor and a dog groomer all take bookings. Each one needs to remember the same few things. Who is coming? What are they coming for? Who will see them? When?
Those four questions give you four data tables. A data table is one kind of thing you keep records of, with a row for each fact you keep about it. Each fact is called a field.
The first three tables are simple lists. Customer holds a name and a way to get in touch. Service holds a name, how long it takes and what it costs. Staff member holds a name.
The fourth table is different. A Booking is not a thing you can point at. It is an event that ties the other three together at a time. It is the table everything else joins to, so it sits in the middle of the drawing.
Drawing this before building anything lets the owner, the front desk and the developer look at the same picture. Most arguments about a bookings system are really arguments about the rules. The drawing brings them out early, when they cost nothing to settle.
Why the booking sits in the middle
Look at each line on the board and read it as a sentence.
One customer makes many bookings. Each booking is for one customer. So the line between them has a "one" end at Customer and a "many" end at Booking.
One service is booked many times. Each booking is for one service. The same shape again.
One member of staff takes many bookings. Here there is a choice to make. Must a booking always have a member of staff, or can a customer book first and be given someone later? If it can wait, the end at Staff member is "One or none". The "One or none" end on the line is a business rule, drawn where everyone can see it.
The Booking table holds a field that points at each of the others: customer_id, service_id and staff_id. A field that points at another table is marked FK, short for foreign key. The field it points at is that table's main ID, marked PK.
You do not need the short names to use the drawing. What matters is that each line starts at the field that holds the link, so nobody has to guess how two tables connect.
The rules to agree before building
The frame at the side of the board is for rules. Write each one as a question, then answer it together.
Can one booking cover two services? Say a cut and a colour are one visit. Either one booking holds several services, or you make two bookings back to back. The second is simpler. The first needs another table between Booking and Service.
What happens when a price changes? A service's price belongs on the Service table. But a booking made last month should still show what the customer paid then. So the price paid is copied onto the booking when it is made, and never changes afterwards. The template's price_paid field is for this.
What does a cancelled booking look like? Deleting it loses the history. A status field, with values such as booked, cancelled and done, keeps the record and lets you count no-shows later.
Can two bookings overlap? For the same member of staff, almost never. For the same room, it depends. If rooms matter, they need a table of their own.
How much do you keep about a customer? Keep only what you use. Every extra personal detail is something to protect, and something a customer can ask you to hand over or remove.
Each answer either changes the drawing or confirms it. Either way, write the answer on the sticky note so the reason is not lost.
Using the template on doodleboard
The Bookings database template on doodleboard starts with the four tables joined up: Customer, Booking, Service and Staff member. Each line has its "one" and "many" ends in place and a label you can read as a sentence.
Double-click a table to change it. You can rename it, add or remove fields, and say what kind of information each field holds, such as text, a number or a date. Mark the main ID (PK) and any field that links to another table (FK).
To join two tables, draw a connector from one field's row to another. A new connector between tables starts as one to many. Select it to change either end to One, One or none, Many or One or many.
Test the drawing with real cases before you call it done. Take last Tuesday's diary and walk three bookings through it, including an awkward one. If a fact has nowhere to go, the model is missing a field or a table.
When the shape is agreed, select the tables and choose Copy as code. SQL is the language databases use, and Mermaid is text that draws diagrams. A developer can take the SQL straight into a database, or put the Mermaid version in the project's documents. If a database already exists, paste its SQL onto the board instead and the tables appear already joined.
Questions people ask
Do I need to know SQL to use this template?
No. You change tables by double-clicking them and typing in a form. SQL is only there for a developer who wants to copy the finished model into a database, or bring an existing one onto the board.
Should staff working hours go in this model?
Add them when the system must stop bookings outside those hours. That needs a table of shifts joined to Staff member. If the front desk checks by eye, leave it out and keep the first version small.
Where does a payment go?
In a table of its own, joined to Booking. A booking can have no payment yet, one payment, or several if a deposit is taken first. Keeping payments apart also keeps money details away from the diary.
