Timeline for SQL Server: specifying a unique optional column
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 22, 2018 at 21:32 | comment | added | Manngo |
+1 for the suggestion, though it’s one I have already explored for a different reason. I refer to this as a one to maybe relationship (why not?). The added benefit of a solution such as this is that if you remove the not null and unique constraints on tfn (the fact that employee_id is a primary key should be sufficient), then you can infer why then TFN is missing. A missing row could indicate that there is no TFN, while a row with a NULL TFN could indicate that there is a TFN but that it is unknown. I blogged about this regarding a date of death column.
|
|
Mar 18, 2018 at 20:19 | comment | added | Manngo | I might comment that other RDBMS this is probably unnecessary — most of them accept multiple nulls in a unique column anyway. | |
Mar 18, 2018 at 18:23 | history | edited | Joel Brown | CC BY-SA 3.0 |
Added justification for answer.
|
Mar 18, 2018 at 15:25 | comment | added | ypercubeᵀᴹ | +1 for this because it also works in even older versions, that don't have filtered indexes. | |
Mar 18, 2018 at 15:10 | history | answered | Joel Brown | CC BY-SA 3.0 |