On 7/22/06, Michael Bayer <[EMAIL PROTECTED]> wrote:
tried this on postgres, with one column constrained by two separate
constraints to two different tables (one part of a composite key and
the other a single key), and while you can safely avoid the foreign
key constraint on "order_item" by having
"order_adjustment.order_item_seq_id" as NULL  (which is amazing), you
cant put a row in "order_adjustment" where "order_id" does not match
a value in "orders", regardless of the value of "order_item_seq_id".
therefore, you wouldnt want to CREATE the foreign keys that way in
the database since the pattern would not work.

In my case it happens that an order_adjustment can not exist indepent
of an order, because if it is related to the order_item, the
order_item will be restraint by a foreign key constraint based on
order_id.


anyway, since the relationship doesnt translate into SQL constraints
very well, thats why the mapper is the better place to express the
relationship instead of the Table (and why SA separates tables from
mappers in the first place).

I find the separation between mapper and table a great advantage which
allows much flexiblity for the programmers. I didn't expect SA can
handle this kind of relationship so easily. Great!

--
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to