Aaron Bertrand has an interesting use case:
A problem that comes up occasionally with constraints in SQL Server is when a unique constraint applies to multiple columns, but the values in those columns can be populated in any order. For example, if a table holds interactions between two users, and has columns
User1
andUser2
, there should only be one row allowed for users 100 and 200, regardless of whether the data is entered as100, 200
or200, 100
.
Click through for one solution. Another solution would be to normalize this down further with a dbo.ConversationParticipants
table.