Schema for scarce goods

database-designschema

I have following objects:
(Rooms) which are (available in a certain period of time [in days]).
During the time of availability they can be (booked) by (users). There are basically these four tables. I know that there is a foreign key in (booked) for (users), I also have a foreign key for (rooms) in (booking) and I do have a foreign key of the (room) in (availability). But how can I connect my (availability)-table to avoid that the good is booked on a period of time it isn't available?

The refered question didn't lead to an answer in my matter.

To summarize:
(Rooms) – (availability) – (booking) – (User)

I have a hard time figuring out how I set the foreign keys for this transaction.

enter image description here

Best Answer

The most relational way is adding a day table. You will be able to join room, availability and day to find out which rooms are available for a certain period.