Re: auto PKs

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sat Oct 11 2003 - 18:16:51 EDT

  • Next message: Andrus Adamchik: "[ANN] Release 1.0.1"

    On Saturday, October 11, 2003, at 04:59 PM, Mike Block wrote:
    > The issue:
    > duplicate key insertion.
    >
    > Basically, I have a Contact table which is shared by 2 other tables,
    > Dealer and Rep. Each Dealer & Rep "hasa" Contact.
    > Dealer.ID <-->Contact.ID [IDs are PKs in these tables].
    > Rep.ID <-->Contact.ID
    > There can be no To Dep PK between these tables since the Contact
    > belongs to either a Rep or a Dealer [or possibly neither].

    I see, this is an interesting case since both Dealer -> Contact and Rep
    -> Contact are logically master->dependent one-to-one relationships,
    but technically Contact primary key is generated independently. Is it
    possible to redesign the schema to make "contactID" a FK on both Dealer
    and Rep? Or the other way - add dealerID and repID FK to Contact? Aside
    from the problem you mentioned below, this seems cleaner to me.

    > The error occurs when it runs the second test, regardless if they are
    > reversed. The PK used for the Contact is used in the second test.
    >
    > Also, if I create a single test by combining the two, the same issue
    > occurs. [This eliminates the setUp/tearDown of the DataContext.]
    >
    > Finally, if I dup the first test so that we either add Dealer, Dealer,
    > Rep OR Rep, Rep, Dealer
    > The error occurs on the 3rd test; so adding Dealer, Deal, Rep fails on
    > Rep [Rep, Rep, Dealer fails on Dealer].

    I guess I need to create a similar combination of relationships in
    Cayenne test cases and see how it behaves. I do suspect problems with
    this case... And again, I would recommend redesign (see above) to
    reconcile the differences between logical meaning of relationships and
    their technical implementation.

    Andrus



    This archive was generated by hypermail 2.0.0 : Sat Oct 11 2003 - 18:16:54 EDT