user3117357
user3117357

Reputation: 45

Delete on cascade in other direction

Is there a way to use the ON DELETE CASCADE option in the other direction? (DB2)

I have a (A one-to-many B) relation and delete one item from B and I want that the item A which is a foreign key from B also will be deleted.

Is that possible ?

Upvotes: 3

Views: 516

Answers (1)

James Anderson
James Anderson

Reputation: 27488

Your request makes no sense.

You seem to want to delete A whenever a single B is deleted -- but deleting a would cause a cascade delete of all related Bs.

Also logically the definition for a default ONE to MANY is "A may have zero or more Bs".

In a physical design this must be the case. A customer record must exist before any orders can be placed against the customer so at some point you have to have a customer with no orders.

Upvotes: 1

Related Questions