I am slightly confused about one task regarding usage of unique constraint. I've got two tables:
The requirement is that table ROOM has room code which must be unique only within a particular building (i've got 4 buildings). Not really sure how to do that. Any ideas?
Thanks is advance.
You can have a unique index across multiple columns, so presumably your "room" table would have a unique index on the combination of room number and building id.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Thanks for the reply. Maybe you could give me some example how to do that?
I've got 4 buildings:
Each building has 4 rooms:
Room code is unique only within a particular building:
1A, 1B, 1C, 1D.
2A, 2B, 2C, 2D.
3A, 3B, 3C, 3D.
4A, 4B, 4C, 4D.
How can I make a constraint from this?
so, add table BuildingRooms with biuldingId, RoomId and it is unique compbination
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)