Hi: I'm working in a pylons application and I have a DB which has the following structure (I haven't depicted the many-to-many tables between, for instance, a computer and a rule for the sake of simplicity):
----------------- ---------------------- ------------------------------------- | computers | | computer_sets | | computer_sets_computers | ----------------- --------------------- -------------------------------------- id id <----------\ id name name \ name description description \ description rule_id ---| rule_id --\ \ ip | \ \ ip | \ \------------ computer_set_id | \ | -------- \ | | rules | \ | -------- \ |----------> id <-----------\ name description enabled There are some points to highlight: 1) A computer_set is only a container of computer_set_computer entities. However, a computer_set_computer is almost identical to a computer entity, with only one difference: a computer entity can be in a rule alone while a computer_set_computer cannot be in a rule; it is considered to be in a rule only as part of a computer_set 2) I have created classes for each of these entities: Computer, ComputerSet, ComputerSet_Computer, Rule However, I have to do the following: I need to be able to query my DB for both Computer and ComputerSet_Computer objects. I mean, I need to display the list of those computers no matter whether or not they belong to a ComputerSet (though when iterating through those objects, I need to know the type of the object). Furthermore, I need to get a Query object to be able to apply slices (to control pagination :) and gain performance. I have tried using UNION and UNION_ALL between the computer and computer_set_computer tables, but I get errors because the tables don't contain the same number of columns. Thanks for your time, Sandor -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.