asp.net mvc 3 - A Simple approach to implementing a multi level library with only one parent node, especially with MVC3/EF -


i trying implement multi level library. there single parent nodes:

parent1    - child1    - child2 parent2    - child1    - child2 

i started implementing using link table

libraryitem -< libraryitemlink (fkparentid)             -< libraryitemlink (fkchildid) 

which fine, , powerful since allows multiparent nodes multichild nodes. have got difficulties when trying delete parent library items. ideally 1 should put "cascade delete" on both of constraints cover parent or child node deletion, sql server not think cyclic deletion may happen. wondered whether making life tricky myself , instead should use self referencing association libraryitem.

libraryitem -< libraryitem(children) 

would easier implement, crud perspective within mvc3/ef5 world?

the final option 2 table 2 levels easier, more limited.

thoughts appreciated.

i go parent_id column in libraryitem table, allowing nulls , fk pk of same table.

for cascading delete issue, use instead of delete trigger on table that;

  1. deletes reocrds parent_id pk of row being deleted
  2. then delete record of parent itself.

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -