Schema for scarce goods

Database Administrators Asked by empedokles on September 5, 2020

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

One 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.

Answered by Federico Razzoli on September 5, 2020

Add your own answers!

Related Questions

SHOW INNODB STATUS averages calculated

1  Asked on November 28, 2021 by antonios


IDE Access to Hive without user password?

1  Asked on November 28, 2021 by mayak


Daily Value of Stock Portfolio Postgres

1  Asked on November 28, 2021 by danields


How to remove dbcreator server role?

2  Asked on November 28, 2021 by andrea-antonangeli


why binlog doesn’t log the DML statement?

1  Asked on November 25, 2021 by lawrenceli


How to promote hidden mongo node to primary?

2  Asked on November 25, 2021 by sweeti-bharti


SQL Get Users By One Group But Exclude Others

1  Asked on November 25, 2021 by dangerman1988


Can’t find missing packages Oracle Linux 8

2  Asked on November 23, 2021 by cute-cake


Cassandra nodes are not equal

1  Asked on November 21, 2021 by ekrem-gurdal


MySQL sql_mode for remote access

1  Asked on November 21, 2021 by lakshmikantha


Error: MySQL shutdown unexpectedly

2  Asked on November 21, 2021 by md-maruf


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir