Back to list
Views:   4.4K
Replies:  1
Archived

Composite Pattern Persistence

What is the best way to persist a tree object to a SQLtable with as few database roundtrips as possible?
Larry Brooks, Aug 05, 2014
Reply 1
Without knowing the details of your data model, I would suspect there is no pattern-based shortcut.  

Most likely you'll have to iterate over the nodes and save the appropriate changes (INSERT, UPDATE, or DELETE). However, having said this, the tree iteration can be done with the Iterator pattern.

Another challenge is when moving nodes within the tree. This may require fairly extensive adjustments of  node records in the database (again depending on your data model)..

Joe Celko wrote a great SQL book discussing tree structures.  Google his name and you'll find it (or search Amazon). 
Jack Poorte, Aug 19, 2014


Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.2.2