Subject Foreign keys and column counts
Author Rick DeBay
I have a table TABLE1 with a three column primary key; one of the three
columns is constrained to two possible values, X or Y. I have another
table TABLE2 that references rows in TABLE1 with two of the three
primary keys, since it is understood that it always references Y rows.
I'd like to create a foreign key from TABLE2 to TABLE1, but I can't
since the column count is different. What I need is something like:

FOREIGN KEY (column1,column2,Y) REFERENCES TABLE2(primarykey)

I know I could create a column on TABLE2 that defaults to the value Y
but that doesn't seem sensible.

Rick DeBay
Senior Software Developer