[wp-hackers] Category Operation (Adjacency vs. Modified Preorder)
Christopher Johnson
agent_eight at hotmail.com
Fri Feb 10 13:33:07 GMT 2006
> > Had anyone ever considered using a modified pre-order tree to store the
> > post categories in?
>
>Excuse the simpleton, but what in hay-diddly is that? Some links and/or
>examples would be helpful.
A modified preorder tree is a method of storing hierarchal data in a
database. This article provides a much better explanation than I'm capable
of ... http://www.sitepoint.com/article/hierarchical-data-database
The method requires a little more work during inserts and updates but allows
for much faster and much more flexible queries. An example ... with this
method you could extract an entire sub tree from the categories table with
only 1 query and no sub-selects (2 joins). No recursive post processing is
needed either. When retrieving posts by category, multiple sub tree's could
be excluded or included with a single query (2 joins). The path to a
category, a list of siblings, a list of children, all can be retreived with
single query, but not at the same time of course.
The multiple inclusion/exclusion of hierarchies feature is what really calls
to me. Granted, doing inclusion "and" exclusion at the same time would
require a couple queries without sub-selects.
If anyone is interested and/or thinks this might be a good addition, I've
got some prototypes I could share.
More information about the wp-hackers
mailing list