Yep we did just that! For more info check the rest of this thread.
On 16-jun-2006, at 15:53, Arnar Birgisson wrote:
What you are describing could be solved with inheritance. You would define a base class and table for Orders and properties common to all orders, and then a seperate class/table for each type with properties specific to those types. Table inheritance is covered in the SA docs, and I think SA can determine what sublcass to use when you load an order - haven't tried this myself though with SA. Arnar On 6/16/06, Koen Bok <[EMAIL PROTECTED]> wrote:Maybe a little metaphor to make it more simple.Let's say I make houses. The roof of the house can either be concrete orwood. Concrete and wood come in many types. Design: House id name Wood id name treename Concrete id name hardnessNow if I have a House object it should have a roof relation which either links to a Wood object or a Concrete object. It NEEDS to be linked to one ofthem. Like this:house = session.query(House).get(1) print house.roof<Concrete id=123 name=SuperBeautiful hardness=500>house = session.query(House).get(2) print house.roof< Wood id=321 name=Oak treename='Oak Tree'> On 16-jun-2006, at 5:24, Michael Bayer wrote: whats wrong with this ? order_types --------------- type_id name from_stock_id to_stock_id ? On Jun 15, 2006, at 6:44 PM, Koen Bok wrote:Within my organisation we have orders. Orders move products between threeentities: Suppliers, Stocks and Customers.The type of an order gets defined by the origin and the destination it ismoving products. This way we can have the following types of orders: From: To: -> Stock BUYORDER Stock -> Supplier RETOURBUYORDER Stock -> Stock INTERNORDER Stock -> Customer SELLORDER Customer ! -> Stock RETOURSELLORDER How can I design objects/mappers to do this:order = session.query(Order).get(1) print order.type<Type id=123 name='INTERNORDER' from=<Stock id=2> to=<Stock id=4>><Type id=456 name='SELLORDER' from=<Stock id=4> to=<Customer id=1928>>order = session.query(Order).get(2) print order.type_______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users_______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users