In the table A, I've got a composite of 3 fields as a primary key and in the table B I've got one of the composite (which is not unique). I'd like to reference with the table A to ease the delete (with ON DELETE CASCADE).
So, am I compelled to put the other two fields in the table B and reference with this composite or is there another solution?
If you want to create a foreign key constraint between the two tables, the child table would have to have all the columns that comprise the primary key constraint on the parent table (which is one of the reasons that I would discourage the use of composite primary keys). If you want Oracle to automatically delete a child row when then parent row is deleted, you need a foreign key constraint with ON DELETE CASCADE. So your options are
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With