October 8, 2002 at 12:41 pm
I'm trying to create a table relationship whereby a field in one table will not allow a value if it doesn't exist in a specific field of a first table. The problem is, the field in the first table is not the primary key. Can this be done?
October 8, 2002 at 1:08 pm
It could be done easily with an insert, update trigger.
October 8, 2002 at 1:11 pm
how?
October 8, 2002 at 1:34 pm
give me the table names, and field names involved, and I'll write it for you....
October 8, 2002 at 1:38 pm
The field "A_Number" in the table "C_Cases" should not allow a value unless the same value appears anywhere in the field "A#" in the table "T_Data"; but "T_Data" is not the primary key.
October 8, 2002 at 4:18 pm
No need for a trigger, just make sure the column of the first table is at least a candidate key. You can do that by adding a unique-constraint on it.
--
Chris Hedgate @ Apptus Technologies (http://www.apptus.se)
October 9, 2002 at 8:43 am
He's right. That would be more efficient as well. Assuming the column's data will allow a unique constraint.
Will that work for you?
Edited by - Scorpion_66 on 10/09/2002 08:45:16 AM
October 9, 2002 at 9:37 am
quote:
Assuming the column's data will allow a unique constraint.
If it doesn't, the design is not a very good one. If there are several rows to match the foreign key with, which one is it that is meant?
--
Chris Hedgate @ Apptus Technologies (http://www.apptus.se)
October 11, 2002 at 4:48 pm
the unique constraint did the trick. thanks
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply