I have a look up table dbo.DecisionReasonCodes, which has a compound primary
key, reasonCode ,char(2) and DecisionCode, char(1).
I have the following Data in the table:
DecisionCode ReasonCode
D 01
D 02
D 03
W 01
W 02
W 03
In a data table called dbo.applications table, I have added nullable two
columns, DecisionCode and ReasonCode.
I was surprised to find out that I can create a record in my
dbo.Applications table with the following combinations:
ApplicationID DecisionCode ReasonCode
1 NULL 01
2 D NULL
3 P NULL
4 NULL 09
Only time I get constraint error is when I enter non-NULL values in both
DecisionCode and ReasonCode columns that are not in dbo.DecisionReasonCodes
Unless I am mistaken I didn't think one can enter any combination of
DecisionCode and ReasonCode in dbo.Applications table that are not defined in
dbo.DecisionReasonCodes table.
I used 'with CHECK' option for the foreign key to dbo.DecisionReasons table
from Applications table for the two columns.
Any help on this confusion is greatly appreciated.
Sang Nahm