Hey guys,
First off I apologise for the lengthy post. But read on and it may peak your interest :)
I have recently been given the task of modeling some hierarchical data in my 5.0.45 installation. I'm using the 'Nested Set Model' as dictated in the following article:
http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
(props to Mike Hillyer :))
I believe I have everything I need to model the data in place, with some storred procedures to help create the tree-like structures in my underlying DB table. (Like add node, delte node, rename node ... etc) Now my issue is to define an "XML-esque" way of communicating these tree like structures from the Ruby app as parameters to my sprocs.
We know that sprocs can only take a finite and predetermined amount of arguments. Passing dynamically sized lists of arguments can be accomplished by passing a single delimited string for which the sproc would then split and process each item in turn.
Taking that a step further suggests passing a big-ass XML-like string as the singe string parameter which could get hectic and unpleasant. I should look up some XML parsing algorithms for some insight but I was wondering if anyone else out there has experience with this sort of thing.
Why not have the app call the sprocs directly? At this point I am against having that happen as I ultimately need to make another sproc to process the tree and thus will need to guarantee not only a integral and legit tree structure at all times, but also a guarantee the preservation of a certain context (ie: only certain elements may appear as the leaf nodes and other certain elements must be on the first depth .. etc)
So ultimately my question is:
What is the easiest way for a Ruby app to dictate a tree-like structure to a mysql installation?
Thanks everyone!