i'm still around doing this, http://groups.google.com/group/sqlalchemy/browse_thread/thread/4e64140af34dc297
basicaly i'm hitting multiple inheritance but that's the OO way of doing multiple aspects, so i hope i dont need it really. the idea is: - couple of base hierarchies A, B(A), C(B), D(A) (e.g. depts/etc; these may link to each other) X, Y(X) (e.g. persons/etc) P, Q(P), R(Q), S(P) (e.g. documents; they link persons and depts-and-like, and also may link to each-other) - several aspect-bases: - hasTimes /versions - there are many versions of same item, timestamped - hasValues and hasRules - values and rules have their own way of value-inheriting/seeing/shading each other, depending where their carrier is in the path in the tree. so A-and-heirs has Times and Values and Rules aspects P-and-heirs has Times and Values aspects X-and-heirs has Times and Rules aspects the queries one may want: - state in time: for some document R1, all the Values (with eventualy their owners state) valid for some Time, walking all the links off R1 then deeper - history for period: for some document R1, all the Values (with eventualy their owners) valid for the period, walking all the links off R1 then deeper - same things about Rules - same things for all documents about person Y2, etc... combinations the links mentioned above may change in time, e.g. R1 may have been initialy pointing Dept1 but later has another version correcting it to Dept2. Or an appendix S1 has been created, rerouting it temporary to Dept5. the actual schema is a bit more complex but this should be enough to understand the issues. what i've invented so far: - all objects inherit Times-aspect but in a concrete-table way; i.e. all have the relevant columns and behcaviour but are not easily combinable in one query unless in same base-hierarcy. concrete-table is because otherwise everything shares same root base and that mapper will be ... ugly. - Value-carriers have a "ownership" m2m to the Values. As here multiple hierarchy-bases meet together, the link to them is done via a "switching reference" - multiple reference-columns/foreign-keys and a type-discriminator yielding just one real link at any time - Rules are bundled inside Value-carriers - no other chance so far the result is that the thing sort-of works, but the queries are very complex (e.g. think of a 5-level tree expanded), and when time-checking is added at each level of the walked links, it gets sloooooow - on an example db of around 50 records all together (1 person, 2 docs, 3 depts, 1-2 values each). i can put Times back as common base of everything via joined inheritance, which will probably solve the above but break something else. what i am thinking is some sort of pyprotocols-way separating aspects from inheritance. (or java's interface? dunno; i've no idea how hibernate is handling interfaces - if at all). so: - have table TimeAspect (or ValueAspect or RuleAspect) - the objects will have a unique reference to whatever aspect they need (so far same as joined-inh), but not as primary key (i.e. not really joined-inheriting it). Creating any object should create automaticaly a row in all their aspects (same as joined-inh) and link to it. - each of the aspects can define a polymorphic union of (all A backpointing to it, all P backpointing to it, ...) - the polymorphism-layer of the mapper can be used somehow against this polymunion to yield A(and heirs), P(and heirs), X(and heirs), ... from the same query. The query could return a tuple of (Ainstance-or-None, Pinstance-or-None, ...) and some row postprocessor can choose the not-None one out of them - outside or inside the Query mechanics. (As i remember there was some way to split polymorphic query into multiple queries, one per subtype - maybe this mechanism can be used here - although this will lose ordering grouping etc). this would give a way to issue polymorphical queries along any of the aspect-trees and not just the base hierarchies, having the aspect-common things in the same table - for easy filtering, indexing etc. e.g. it would be easy to say 'give me *anything* that has changed betwen t1 and t2'. is this doable? i can go on try hack it myself; maybe i can try do it all above SA first, then see what part can be embedded ciao svilen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---