0

I have the following schema :

enter image description here

When i perform deletion on each model, we need to delete all its children too. Please suggest me the best way. Thanks before.

Amirhossein Mehrvarzi
  • 18,024
  • 7
  • 45
  • 70

1 Answers1

1

i would not advice ever using cascading deletes as you are giving the computer control of what gets deleted/updated this is bad practice. as on large scale database models and top sensitive data if you something deletes its self you are going to be answering question on why has data gone missing.

the best way to delete all child items would be to have two methods

public static class DeleteMenu()
private static class DeleteMenuItems()

in the delete menu method first of all call DeleteMenuItems and remove all children then delete the menu item its self

Luke Franklin
  • 355
  • 1
  • 11
  • True. But Consider that when have not cascade delete in this schema, there will be entities without parent for menuitems and cause application to have some anomalies. Doing this may be a policy more instead of technique. – Amirhossein Mehrvarzi Jul 19 '13 at 10:58