I have a table with a primary key, and also a field called 'tpid', which is sometimes null, and sometimes has an integer value in it. This integer value corresponds a primary key in another table, and that key is also called tpid.
I would like the following to happen.
If a row in table 1 is deleted, and it has a tpid that is not null, then I want the corresponding row in the second table to be deleted too.
I think a trigger could be written to do this, but it would be better if a foreign key constraint with cascade delete could be used.
One reason that is better is that whenever I script out my database, triggers seem to be left out by default, unless I specifically ask that they not be..
So can this be done - where column in table 1 has some nulls, and is not a primary key, but when its deleted, you want to delete a matching row in a table where it IS a primary key.
Thanks,
Gideon