Re: having two sep. foreign keys with same table

From: Dhruti Ramani (dhrutiraman..ahoo.com)
Date: Tue Jul 05 2005 - 10:12:05 EDT

  • Next message: Dhruti Ramani: "DataObject states"

    if I do whatever you have explained here and try to assign some user to Deal as Primary Contact it will automatically add that user as Secodnay contact too or either way.
    here is what I have tried,
     
    Deal has two attributes priContact_id and secContact_id. SystemUser has systemUser_id as primary key.
     
    I have one relation "PrimaryContact" with join Deal.priContact_id=SystemUser.systemUser_id and the reverser relation is "DealsForPriContact(to Many).
     
    Another relation is "SecContact" with join Deal.secContact_id=SystemUser.systemUser_id and the reverser relation is "DealsForSecContact(to Many).
     
    No "toDep" checked. Am I missing something?
     
    Sorry could not get chance to do this earlier and i have to ask the question now.
     
    Thanks,
    Denna

    Andrus Adamchik <andru..bjectstyle.org> wrote: Denna,

    In Cayenne terms you'll have to add 2 DbAttributes to the Deal DbEntity. I
    would call them "primary_contact_id" and "secondary_contact_id" (if needed
    adjust the names to follow your naming convention for DbAttributes).

    Then map 2 corresponding DbRelationships to SystemUser using the following
    joins: (Deal.primary_contact_id/SystemUser.id) and
    (Deal.secondary_contact_id/SystemUser.id)

    Andrus

    P.S. For those who are wondering what this is all about, it is a followup
    on this message (and some offline discussion that we had):
    http://objectstyle.org/cayenne/lists/cayenne-user/2005/06/0019.html

    > Andrus you said,
    >
    > Join on "deal_id" is probably wrong (it seems to be done backwards). If
    > I understand correctly what you are trying to achieve, I'd say Deal table
    > should have two separate foreign keys pointing to SystemUser primary
    > key
    > (e.g. Deal.primaryContactId and Deal.secondaryContactId). Map
    > relationships using those keys. Both forward and reverse relationships
    > should work.
    >
    > Andrei
    >
    > SystemUser has one primary key systemUser_id how do I add two foreign keys
    > for this in Deal in cayenne modeler?
    > Thanks,
    > Denna
    >

    __________________________________________________
    Do You Yahoo!?
    Tired of spam? Yahoo! Mail has the best spam protection around
    http://mail.yahoo.com



    This archive was generated by hypermail 2.0.0 : Tue Jul 05 2005 - 10:12:08 EDT