I want a column from a table to have a limited domain, which is listed in a different table. Usually, I’d just do this:
ALTER TABLE Table1
ADD CONSTRAINT FK_Especialidade FOREIGN KEY (column1)
REFERENCES Table2
However the values that “column1” must reference should not be a Primary Key in Table2. Any suggestions?
You could use a trigger (this is off the top of my head, the syntax might not be right…)
Make sure you at least have an index on column2 in Table2, you want your triggers to execute as fast as possible!