T
T
Turtle_Onni2018-09-06 12:17:08
C++ / C#
Turtle_Onni, 2018-09-06 12:17:08

How to pledge cascading deletion?

Hello!
During the deletion of data from the code - this transaction is fixed, but in the database there is also a cascade deletion. How to commit subsequent data deletion transactions during a cascading deletion in the database?
Thank you very much in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kuznetsov, 2018-09-06
@DarkRaven

Where do you want to fix it?
Cascading deletion occurs, as you know, due to the fact that your foreign keys have ON DELETE CASCADE. In my opinion, it’s better here ON DELETE NO ACTIONthat it will force you to manually delete all related data that refers to the object being deleted, which will lead you to full control of the deletion process with transaction fixation, context information recording, etc.
In general, the business usually does not allow deletion, only mark as deleted, with the preservation of information about who, when. Here we do it simply UPDATEand set the necessary fields, but, again, we do it for all related data that depends on the object being deleted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question