I'm sorry to come up again with a complex query question but I simply
couldn't find a simple solution for this.

My schema is the following: there are zoos, zoos have cages, cages
have animals. And to any of these objects comments can be associated.
For a given zoo I need to select all comments that are either:
comments on the zoo OR comments on a cage belonging to this zoo OR
comments on an animal belonging to a cage belonging to this zoo.

The schema is this:

class zoo( SQLObject ):
    cages = MultipleJoin( 'cage' )

class cage( SQLObject ):
    animals = MultipleJoin( 'animal' )
    zoo = ForeignKey( 'zoo' )

class animal( SQLObject ):
    cage = ForeignKey( 'cage' )

class comment( SQLObject ):
    object_id = Int( ) # this is the 'id' of the object this comment
is associated to
    object_ = StringCol( validator=OneOf( [ 'animal', 'cage', 'zoo' ]
) ) # type of object
    content = UnicodeCol( ) # the actual comment

It might very well be the case that this setup is not optimal but
unfortunately I can't change it. So given a zoo instance with comments
on zoos, cages and animals, does anyone know an elegant query that
will select all comments that belong either to this zoo instance or to
any cage in this zoo or any animal that is in a cage in the zoo?

Thanks very much for any help,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to