On Dec 4, 2008, at 7:44 AM, Guillaume wrote:
> > The problem is not directly in the inheritance scenario, but rather > creating an association to an abstract class. > > Let's say I have the following classes: CorporateCustomer and > PrivateCustomer inheriting from the abstract class Customer. On the > database side, I have the two following table: corporate_customer(id, > customer_info, corporate_info) and private_customer(id, customer_info, > private_info) (ids are generated by a unique sequence for all the > database). Now I have also Order objects associated to Customer > objects; the table looks like order(id, customer_id, order_info). Can > I map this scenario directly in SQLA without creating some dummy view > customer in the database ? sure this is called "concrete table inheritance". Though when you make a relation to Order, you need to declare these separately for CorporateCustomer and PrivateCustomer since the connection from a relational perspective is different. When concrete inheritance uses an abc, it maps to a union of the subtables so that you can load polymorphically. To do that with declarative you'd also have to create the Table objects separately and pull them in to each class using __table__. So with those limitations, if it were me I wouldn't use the concrete inheritance feature unless i needed to load "Customer" objects generically, I'd instead use "Customer" as a mixin class stated after the declarative base class. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---