(Edited 6/4)
I am designing a database that contains the following tables about hotels and their locations (in the context of this question let's say hotel names are unique):
[Hotel]
HotelId PK
HotelName AK
[HotelLocation]
HotelId FK
HotelLocationName
(HotelId, HotelLocationName) is the PK in HotelLocation. There cannot exist two HotelLocations in the same Hotel with the same HotelLocationName.
Some sample data could be:
| Hotelid | HotelName | | HotelId | HotelLocationName |
---------------------------- -------------------------------
| 1 | Holiday Inn(1) | | 1 | Reception |
| 2 | Four Seasons | | 1 | Pool |
| 3 | Holiday Inn(2) | | 2 | Reception |
| 2 | Dinning room |
| 3 | Room 100 |
| 3 | Room 101 |
It is required that both HotelName and HotelLocationName are editable.
For that reason, in the case of the Hotel table I use a generated immutable HotelId and keep the HotelName as an alternate key (AK) with a unique constraint.
I could do the same for the HotelLocation table and change it like:
[HotelLocation]
HotelLocationId PK
HotelId
HotelLocationName
where (HotelId, HotelLocationName) is an AK.
The problem is that I have a lot more tables related with it, where an FK like (HotelId, HotelLocationName) gives me a direct relation to the Hotel that i don't want to lose.
I know I can still use a similar FK to HotelLocation's AK but the problem with cascading updates remains.
I though about generating the HotelLocationId in a way that i can have a (HotelId, HotelLocationId) PK, for example taking the MAX(HotelLocationId) + 1 for a specific HotelId for every new record, but I would prefer an alternative solution if there is one.
Is there any common way to deal with this kind of situation?