SQL Server:
How to do it:
The best way is a filtered index. Uses DRI
SQL SerferServer 2008+Computed column with uniqueness. Uses DRI
See Jack Douglas' answer. SQL Server 2005 and beforeAn indexed/materialised view which is like a filtered index. Uses DRI
All versions.Trigger. Uses Code, not DRI.
All versions
How not to do it: