Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Best Design for a booking system

Best Design for a booking system

Best Design for a booking system

I am trying to create a booking database...but the design I keep coming up with makes me a bit uneasy.  I don't really like it (because of massive joins involved in determining what time slots are available) but I don't see any other way to do this.  So this is my design.

--This table stores incidences of booked time slots
BookingStartDate (DateTime)
BookingEndDate  (DateTime)

--This Table stores the generally available booking times for each week.  Eg.  If users can book from 9:00am to 5:00pm monday to friday then there would be an entry with
slotstarttime = 9:00, slotendtime=17:00,sun=false,mon=true,tue=true, wed=true, thur=true, fri=true, sat=false

SlotStartTime (Time)
SlotEndTime (Time)
Sun (boolean)
Mon (boolean)
Tue (boolean)
Wed (boolean)
Thur (boolean)
Fri (boolean)
Sat (boolean)

--This table stores any possible exceptions that might occur outside of the general booking times (eg a holiday).  bAvailable determines if the exception allows for a new booking, or cancels an existing one.

Table: Booking_Exceptions
SlotStartDate (DateTime)
SlotEndDate (DateTime)
bAvailable (boolean)

I use General_Avail_Booking and Booking_Exceptions to determine the possible times when users can actually book a time slot, and then store what time slots users book in Booking_Incidence.

RE: Best Design for a booking system

Hmm an event can have several sites booked by several parties on multiple dates and times.

A contract should cover the number of people, seating required, resources required, Setup time, event time and Cleaning time.  We also include security for the event for which there is a charge.

Well you could have some kind of table that just shows avail booking that has fields like

5.min.time.slots.1-288 boolean

That way you can search by month by day and by year.  Basically you would build 365 records with no time slots filled.  Then use your events to mark the time slots filled and every time you have every 5 min interval marked for free or not.  Does not have to be 5 min intervals.  You could use 15 min or 10 min intervals or half or full hour intervals.  You could use the date instead of month day year or use it as an alternete index.

Every time you book an event you mark your table to show occupied or when deleting events change their boolean status on the table.  You might want some way to rebuild it in case of a problem.  The think is you really need every day of the year built before you can store the results from a booking.

If you do not like my post feel free to point out your opinion or my errors.

RE: Best Design for a booking system

I like your post.  It is a good example.  I was hoping I could avoid mapping out everyday of the year however  Anyway, my system has a couple considerations that makes it hard to adapt to your system.  First, I think your sysem requires all the time slots to be the same length right (eg all 5min, or all 10 min, etc).  I need a way to have variable timeslots.  Also, I was really really hoping not to map out every day of the year (cause this means that I have to constantly be adding new booking times to my table as time progresses).

One thing I noticed was that in your Venue_Usage_Table, you broke out the date into 3 columns, year, month, and day.  I've seen this before but I've never really understood why it is necessary.  If you just had a single date field, you could still search by day, by month, and/or by year using month(date), day(date), year(date).  Why do people break up the date field?

RE: Best Design for a booking system


Why do people break up the date field?

Depends on the language. Some (like FoxPro) have good commands that can take a date field to bits and give you the day, the month, the year, the name of the day or the name of the month or the week number or the Julian Day or whatever you want. Others don't and it's easier to store the day, month, and year as three separate items.

Geoff Franklin

RE: Best Design for a booking system

On the date if you want to look at only wednesdays or only at august how would you do that without using a function and taking a longer time to run the querry?  Also you may want to look at only one year or for three months.  I know in out database we use the date as a number of days since some arbitrary date and use a conversion string when we display it.

Anyway on this subject we also use a room scheduling/event software called R25 or Resource 25.  We use it with Datatel Colleague Education software, I dont know if it works with other products or not.  We are still working on implementing it but it uses formulas to write contracts, an d schedules rooms etc.

If you do not like my post feel free to point out your opinion or my errors.

RE: Best Design for a booking system

Ok,  I realized a major problem with my design.  I was thinking of it as one system (for booking) but what it really is is two systems...one for storing bookings, and one for showing a schedule of available time slots.  It is the schedule part of this problem that I am having trouble with.  Does anyone have a suggestion for this?

RE: Best Design for a booking system

ok, I've come up with a design for showing the schedule. This will work in combination with a simple booking system. What do you think? I realize that my syntax is not proper. Also, I know it is bad to select everything. I was just trying to get the idea out there.

-stores the regular weekly schedule
EffectieStartDate (the start date for using this regular schedule)
EffectiveEndDate (the end date for using this regular schedule)
SchedDay INT (1 to 7...1 for sun, 2 for mon, etc)

-stores exceptions in the regular schedule (eg new booking times, etc)

-this table stores the time slot IDs that a particular exception replaces

Now, to get the schedule for a particular week, I need a stored procedure. This is the basic idea. I'm not sure about using the line ws.FK_TimeSlotID IN (SELECT FK_TimeSlotID FROM exception_replacements WHERE FK_ExceptionID = s.ExceptionID). I think this might be slow and bad programming although I don't really know.

SP_GetWeeklySchedule(startDate DATE, mRoomId INT)

DECLARE Day1 to Day7 as dates starting from the startdate

SELECT ws.*,s.* FROM
   (SELECT r.*,w.SchedDate FROM RegSchedule r
   (SELECT Day1 as SchedDate UNION SELECT Day2 UNION ... UNION SELECT Day7) as w
    On DAYOFWEEK(w.SchedDate) = r.SchedDay
    WHERE r.FK_RoomID = mRoomID AND
       w.SchedDate>=r.EffectveStartDate AND
AS ws


sched_exceptions s ON
   ws.SchedDay >=s.StartDate AND
   ws.SchedDay <=s.EndDate AND
   ws.FK_TimeSlotID IN (SELECT FK_TimeSlotID FROM exception_replacements WHERE FK_ExceptionID = s.ExceptionID)
   s.FK_RoomID = mRoomID AND
   s.StartDate >= Day1 AND
   s.EndDate <= Day7

RE: Best Design for a booking system

If your still interested, I just built something very similar.  It is a booking system for 25 different rooms, with varying time periods.  You can click on a Calendar day view (kind of like outlook) and add or modify reservations.  The strategy I use to determine availability is eloquent, but simple.  Very few joins.  They do not allow users to post email addresses, but I can FTP it if you are interested or have another method.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close