Re: Creating Compound PKs

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Jun 04 2007 - 02:47:20 EDT

  • Next message: John Armstrong: "Re: Creating Compound PKs"

    Hmm... is this even a PK generation question? I understand that "id"
    is a unique PK already? Is there a need to define name/serverid as a
    part of PK as well? I mean you can (and Cayenne will support it), but
    what's the point. Maybe instead you can define a UNIQUE constraint on
    those two columns in your table?

    Andrus

    On Jun 4, 2007, at 9:25 AM, John Armstrong wrote:

    > Yes, sorry misplaced that bit of important information.
    >
    > ImapServer
    > account
    > id
    > password
    > serverip
    >
    > Tx
    > John-
    >
    >
    >
    > On 6/3/07, Andrus Adamchik <andru..bjectstyle.org> wrote:
    >> Hi John,
    >>
    >> A question - is "serverid" a foreign key to another table by any
    >> chance?
    >>
    >> Andrus
    >>
    >>
    >> On Jun 4, 2007, at 9:09 AM, John Armstrong wrote:
    >>
    >> > Does Cayenne allow for the creation of a compound PK? I searched
    >> the
    >> > archives and google more generally and could only find hints at
    >> this.
    >> > The docs did not clarify either (although it was also hinted at. .I
    >> > think, its a bit late :) ).
    >> >
    >> > My table looks like this:
    >> >
    >> > id
    >> > name
    >> > serverid
    >> > status
    >> > enabled
    >> >
    >> > I need to create a compound PK on name/serverid that will maintain
    >> > uniqueness across these segments.
    >> >
    >> > My fallback is to create a validation that checks these before
    >> commit
    >> > but my normal route in a non-ORM context is to let the DB
    >> enforce it
    >> > and catch it there.
    >> >
    >> > Thanks!
    >> > John-
    >> >
    >>
    >>
    >



    This archive was generated by hypermail 2.0.0 : Mon Jun 04 2007 - 02:47:42 EDT