On Jan 16, 2010, at 2:41 PM, justin potts wrote: > Michael Bayer wrote: >> On Jan 16, 2010, at 1:02 AM, justin potts wrote: >> >> >>> I realize it's not the typical case, but I would like to know if it's >>> possible to map a class to multiple tables at once, somewhat like >>> mapping to a join statement. I've read the documentation about >>> querying with joins, however this seems like a large amount of work to >>> build an object sourced from multiple tables. Any help is appreciated. >>> >> >> what scheme for representing objects along multiple tables did you have in >> mind ? this can mean any number of things. > I'm wondering if it's possible to instantiate an object with properties from > different tables. Since it's usually a 1-1 mapping, I suppose the scheme in > this case would be many-to-1.
If the relation is truly 1-1 in all cases, it seems most likely that your scheme is what SQLA calls "joined table inheritance". Fowler calls it "class table inheritance": http://martinfowler.com/eaaCatalog/classTableInheritance.html . Docs for this method are at http://www.sqlalchemy.org/docs/05/mappers.html#joined-table-inheritance . Otherwise, if you are leaning more towards many-to-one, or one-to-one but its really two distinct entities being represented, you can represent state across multiple tables using composition of objects, for which you use relation().
-- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. 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.
