Wednesday, 23 June 2021

On Cascade Delete

ON DELETE CASCADE

It specifies that the child data is deleted when the parent data is deleted.


When two entities(tables) are associated, one entity pointing to another using an FK. 

A Client has many Orders, then normally FK is kept in Order, and FK references the Client PK. 

The Client is called referenced, or father table; and Order references Client and is also called Children. 

If the referenced Client is deleted, On Delete Cascade means its children are removed by cascaded operations.  


NO ACTION

It is used in conjunction with ON DELETE or ON UPDATE. It means that no action is performed with the child data when the parent data is deleted or updated.


SET NULL

It is used in conjunction with ON DELETE or ON UPDATE. It means that the child data is set to NULL when the parent data is deleted or updated.


SET DEFAULT

It is used in conjunction with ON DELETE or ON UPDATE. It means that the child data is set to their default values when the parent data is deleted or updated.


Data Integrity Issue: 

when removing the father, Children will complain because of the violation of the data integrity. The Children depend on the father, it needs to remove the Children first then removing the father. 




No comments:

Can Jackson Deserialize Java Time ZonedDateTime

Yes, but must include JSR310. Thus ZonedDateTime can be deserialized directly from JSON response to POJO field. <dependency> <g...