I am working on a table that has a compound primary key that includes a date.
Faculty
PersonId StartDate EndDate Title ....
-------------------------------------------------
I will add a compound key consisting of the PersonID
and StartDate
. The business rule I am thinking about is allowing a person added as faculty, removed, and then added again later if needed. I am thinking a visiting professor. Or an adjunct who teaches an occasional course, but is not an active member of the faculty from one semester to the the next.
The end date will allow nulls
, indicating a person is currently a faculty member.
I want to further constrain the data so a person can have only one row with an end date that is null
.
Things I have considered:
- UDF in a check constraint
- Trigger (I hate triggers)
- Application layer constraint (most likely what I will do at this point)
Note:
- This is a hobby, work on this weekends kind of project
- The intended data store is Azure SQL Database