Hello, thanks for answering my post.
For the parent/child relation, I have:
CREATE TABLE `itemRel` (
`idItem` int(4) unsigned default '0',
`idParent` int(4) unsigned default '0',
) TYPE=MyISAM;
Then there's another table holding the string (titleBcrumb) the users sees
CREATE TABLE `category` (
`idItem` int(4) unsigned default '0',
[snip]
`titleBcrumb` varchar(100) default '',
PRIMARY KEY (`idItem`)
) TYPE=MyISAM;
I'm not getting what you mean by "having a pointer to the root-node in each record". Is there any way I can extend my first table (itemRel) to avoid the multiple joins or queries?
For example, to get a 3 level breadcrumb I currently use:
SELECT cat1.titleBcrumb, cat2.titleBcrumb, cat3.titleBcrumb
FROM category AS cat1
INNER JOIN category as cat2 ON cat1.idItem <> cat2.idItem
INNER JOIN category as cat3 ON cat2.idItem <> cat3.idItem
INNER JOIN itemRel as itemRel1 ON cat1.idItem = itemRel1.idParent AND cat2.idItem = itemRel1.idItem
INNER JOIN itemRel as itemRel2 ON cat2.idItem = itemRel2.idParent AND cat3.idItem = itemRel2.idItem
WHERE cat1.titleURL = 'home' AND cat2.titleURL = 'section' AND cat3.titleURL = 'subsection'
Thanks again!!