Question

I have two tables Building & Room, each Room have a buildingID as a FK . but now I want to add a sequence number which represents the sequence of the Room inside the Building. So I am thinking of having the sequence number inside the Room table , which will be as follow:-

  • RoomID (PK)
  • Room_Name
  • Room_Type
  • Building_ID(FK to the Building table)
  • Sequence_number.

But since the sequence number is a info that is related to the Building and to the Room . so is this right to store the Room sequence number within a building inside the Room table , or it is better to have a relation table between a Room & a Building. Regards

Was it helpful?

Solution

Assuming you are not working for some interdimensional hotel chain one Room will allways belong to exactly one Building and never change this relationship, the sequence number is completely fine inside the Room table.

Of course if you are working for some interdimensional hotel chain it is perfectly reasonable to assume that a room belongs to multiple buildings. In that case the question becomes: has it the same sequence number in all the buildings? If yes it should still be part of the Room table. If not it belongs into a Building2Room mapping table.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top