I have a table structure with several 0 to 1 relationships.
1 Resource can have
0 to 1 Temporary Codes
0 to 1 Permanent Codes OR 0 to 1 Store Credits
I'm looking for a way to ensure at the database level that an entry cannot exist in both the permanent code table AND the store credit table. (it should produce an error - as if a duplicate key were being added)
Can anyone think of a design that would ensure this? Or should I use a stored procedure?
Any advice would be appreciated!
edit: To be clear - what I want to ensure is that if I try to insert an entry into Permanent Codes AND Store Credits - this would violate some kind of database rule (Produce an error). In other words, it should be impossible to have both.