[Rails] To RForum devs: Writing a reusable NestedSet
implementation
Sascha Ebach
se at digitale-wertschoepfung.de
Mon Dec 6 04:33:33 GMT 2004
Hi Rick,
thanks for your reply. Now I see why I should have paid more attention
to graph theory ;)
Surely, any form of tree traversal is bound to have performance problems
at one point in time if the tree really starts to fill up. But I guess
this will be the case for any content repository technique. If you want
to read more about the implementation I meant, here are my sources:
http://threebit.net/tutorials/nestedset/tutorial1.html
http://cvs.php.net/co.php/pear/DB_NestedSet/NestedSet.php?r=1.86
http://www.sitepoint.com/print/hierarchical-data-database
http://www.evolt.org/article/Four_ways_to_work_with_hierarchical_data/17/4047/index.html
http://www.intelligententerprise.com/001020/celko.jhtml?_requestid=745072
http://www.intelligententerprise.com/001020/celko1_2.jhtml
Celko is surely the most influential source (in the database field). I
don't have his book yet (SQL for Smarties), but I will probably order it
soon. He gives the example which is usually referred to by everybody else.
What I want to do is quite simply duplicate and rubyfy the code of the
DB_NestedSet php implementation. I think that a lot of "content
management" projects (for example RForum) could benefit from this if it
was really easy to use such a library.
The technique you mention could be implemented later. (Maybe once I
actually understand it ;) For the beginning it would be nice to have an
interface for reading and writing nodes. The developer shouldn't really
need to think about Trees and Nodes.
class Article < Contentnode
def save: end
def move; end
def copy; end
... # do all the node and tree stuff in these methods automatically,
# if possible
end
And then later just change the configuration
class NestedSet
def use_implementation; 'graph' end
end
It would be great if something like this were possible. But for the
beginning I would settle for less complex and more common solution I
mentioned above.
Also very interesting is the Java Content Repository. It is a
specification which tries to standardize the way content is accessed in
an cms like application. Which is a good thing I guess since there is no
standardization at all in this field.
Get the jsr170-0.12.pdf from the download here
http://www.jcp.org/aboutJava/communityprocess/review/jsr170/
The JCR specification talks more about the high level interface to
access content rather than the implementation of the low level access
techniques (where my interests lie right now). This API could be useful
though since I think standardization is a good thing.
--
Sascha Ebach
More information about the Rails
mailing list