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.