On 7/22/06, Michael Bayer <[EMAIL PROTECTED]> wrote:
the column order_adjustment.order_id has two conflicting foreign key
definitions on it, which is not valid. fixing that is the first step.
This design is taken from the book 'Data Model Resource Book', which
calls this kind of pattern 'exclusive arc of a one-to-many
relationship'. The book states:
Exclusive arcs are used to identify relationships where an entity is
related to two
or more other entities, but only one relationship can exist for a
specific entity
occurrence.
With regard of the test script, it means an entity of order_adjustment
can be either related to an order entity or an order_item entity, but
not both at the same time. So if only order_id is present in
order_adjustment, with order_item_seq_id set to NULL, then this
database row is related to an order. If both order_id and
order_item_seq_id are filled for a row, it is related to order_item.
I was testing to see of SA can support this pattern of database design smoothly.
then if you are creating a relationship between mappers using an
explicit primaryjoin, and neither side of the relationship is a
foreign key (which is acually the case here since the ForeignKey and
ForeignKeyConstraint objects on the table are conflicting with each
other), you have to specify the "foreignkey" argument which is a
table column or list of columns that represent the remote side of the
relationship.
Adding a "foreignkey" argument to the mapper does solve the problem.
Thanks for the tip. If there could be any other SA problem with this
kind of database design, please let me know.
--
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