I am refactoring one of my database tables and I've come up with an issue.
Specifically, I have a table with four columns. We'll call the first three my.a
, my.b
and my.c
. I have a uniqueness constraint on the combination of these three columns. Column my.d
is a foreign key to an auto-incremented ID column in another table foreign
.
I realized that this other table also has a column foreign.a
and both column a
s are complete duplicates, i.e., if you join the tables together on d
, my.a
will always equal foreign.a
. Apparently this is part of the requirements.
I would like to remove column my.a
from my table, but that will remove the uniqueness constraint. Is there a way to somehow set up a uniqueness constraint on the combination of foreign.a, my.b, my.c
? Or am I better off just leaving the duplicate column in place?
my.a
column and keep the uniqueness constraint. But another thing you can do, is replacing the foreign keymy (d) references foreign (d)
withmy (a,d) references foreign (a,d)
so what your know see in the database (both column as are complete duplicates) is guaranteed by the database itself. – ypercubeᵀᴹ May 26 '15 at 1:25my.a
– Swiftheart May 26 '15 at 2:09