A
A
accountnujen2022-03-18 20:26:18
Database design
accountnujen, 2022-03-18 20:26:18

How to store free dates for hotel rooms in a table?

Not exactly a hotel. Rather booking or airbnb - that is, the number of rooms is impressive.
You need to find out about free rooms for a given period of time (conditionally, from March 20 to March 25). That is, reflect those hotels in which the specified days are free.

1. What should the table structure of free and busy dates look like?
2. And what should the cost structure of the rooms look like if the whole month can be one cost, and on holidays - another cost?

Should I create a separate table for each leased object, where each entry will correspond to each day? Just in my understanding, sampling can take a long time. Of course, this is faster than if I had a "Objects" table, where each entry is a hotel, and in a column, in json format, I would store an array with days - this is already quite a clinic.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
ReFeRy, 2022-03-18
@ReFeRy

To solve this particular problem, you can have pre-formed tables in the database for each request and hotels, which, in principle, have suitable rooms.
For example:
Request: "2 adults +1 child", we have a table with identifiers of all hotels that have rooms that satisfy this request.
And then, at the time of placing the order, we note in a separate table that it was in this hotel that there were no rooms left for such and such a request for such and such a date.
As a result, at any time, with one request, you can find all the hotels that satisfy the request and for which there are no records for the specified dates that all the rooms matching the request are occupied.
Something difficult screwed up. It is necessary to estimate the specific structure of the database and solve all typical tasks on it.
PS There is a feeling that you want to be sure to look in the database for a record that something exists, but you can check for the absence of the required record =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question