Views: 4.4K
Replies: 1
Archived
|
Composite Pattern PersistenceWhat 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 1Without 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
|