How to design tables for airbnb style booking system [closed]

Posted on

Question :

all. My English is not very good, but I will try to describe my question as clear as possible.

I want to design a airbnb(https://www.airbnb.com) style booking system, this kind of booking system allows somebody books idle resources of the others.

Here is my system needs:

  1. Resource provider can set resources’ available time of booking. The minimum time slot is 1 hour between 9am-12pm.
  2. The default setting can be set as repeat periodically. For example: 5pm-8pm every Saturday available.
  3. Also resource provider can change the time table whenever necessary. For example: stop provide the resource this Saturday because it’s not available temporary.
  4. Other users can book single or multiple time slot of any resource provided by many resource provider as long as it’s available
  5. Booking is open for the next 28 days.

Now I have difficulty in designing tables for the resource provider to set the available time.

Can your guys give me some advice?

Answer :

Use timestamp ranges for booking availability. There is good documentation in official PostgreSQL docs.

You may find this lecture helpful:
Range Types and Temporal: Past, Present, and Future

And my blog post about generating timestamp ranges could also be helpful:
Generating ranges in PostgreSQL

Leave a Reply

Your email address will not be published. Required fields are marked *