From: Ian B. <ia...@co...> - 2004-11-10 05:27:57
|
Ksenia Marasanova wrote: > I solved this: http://sourceforge.net/mailarchive/message.php?msg_id=9996700 > (don't have it in mijn mailbox for some reason) by explicitly > declaring a class for the third (many-to-many) table and adding > "cascade" attribute to the columns of this table. > > Now another question: how to search RelatedJoin? I have a table > Address with many-to-many relation to it self. Address kan have > multiple addresses as parents, and can be a parent on it's own. I'd > like to find all children of given parent. How should I build this > query with SQLObject? Blech; that's a real pain in SQL in general. There's whole books on it (literally). Hmm... I know I've seen several articles on it, but I'm missing them at the moment. Anyway, you have to use different tree representations if you want to do it with a single query. Maybe someone else has an article on this handy. Sometimes I've kept a table that contains all the ancestor relationships, maybe with a degree-of-separation column as well. You have to do a fair amount of bookkeeping to make it work (not at all normal), but it's relatively fast and easy to understand. There's some better algorithms that use different kinds of numbering. Using strings is also easy to understand, along the lines of a path. So '/a/b/c' means c is a child of '/a/b', and b is a child of '/a'. Lots of bookkeeping there as well. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |