How would I set up a constraint for the following scenario:
I've got 2 columns, SSN & an ArchiveFlag. If ArchiveFlag = 1, the row is set to be archived and essentially not considered to be part of the table. If the ArchiveFlag is NULL, the row is active. The constraint would be we can't have duplicate, Active SSN's.
This would be valid:
Row 1: SSN = 123456789 ArchiveFlag = NULL
Row 2: SSN = 123456789 ArchiveFlag = 1
Row 3: SSN = 123456789 ArchiveFlag = 1
Row 4: SSN = 123456789 ArchiveFlag = 1
Trying to add Row 5 would be invalid:
Row 1: SSN = 123456789 ArchiveFlag = NULL
Row 2: SSN = 123456789 ArchiveFlag = 1
Row 3: SSN = 123456789 ArchiveFlag = 1
Row 4: SSN = 123456789 ArchiveFlag = 1
Row 5: SSN = 123456789 ArchiveFlag = NULL
I've got 2 columns, SSN & an ArchiveFlag. If ArchiveFlag = 1, the row is set to be archived and essentially not considered to be part of the table. If the ArchiveFlag is NULL, the row is active. The constraint would be we can't have duplicate, Active SSN's.
This would be valid:
Row 1: SSN = 123456789 ArchiveFlag = NULL
Row 2: SSN = 123456789 ArchiveFlag = 1
Row 3: SSN = 123456789 ArchiveFlag = 1
Row 4: SSN = 123456789 ArchiveFlag = 1
Trying to add Row 5 would be invalid:
Row 1: SSN = 123456789 ArchiveFlag = NULL
Row 2: SSN = 123456789 ArchiveFlag = 1
Row 3: SSN = 123456789 ArchiveFlag = 1
Row 4: SSN = 123456789 ArchiveFlag = 1
Row 5: SSN = 123456789 ArchiveFlag = NULL