I need to save a Tree Structure Data into my database.
At first, I used XML as a attribute to perform this use case, but then I met some concurrency issues.
Now I decide to use table relationship to perform a tree structure, but still met some problems:
in my use case, a TaskRoot is a root of the tree, and a TaskGroup is a child tree, a Task is a leaf node which has no children.
Something look like :
Here this what I try in Model first, (sorry for chinese)
Then I add On Delete Cascade
on the parent side.
An error occurs:
Introducing FOREIGN KEY constraint 'FK_NestedTaskGroup' on table 'TaskGroupSet' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
That makes more sense to delete all the children if the parent node is deleted.
Please tell me how better to save a tree structure?