• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Mixed PKs?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mixed PKs?


  • Subject: Re: Mixed PKs?
  • From: Giorgio Valoti <email@hidden>
  • Date: Thu, 3 Jul 2003 00:11:31 -0700

On Mercoledl, lug 2, 2003, at 16:07 US/Pacific, Ricardo Strausz wrote:


On miircoles, juli 2, 2003, at 07:41 America/Mexico_City, Giorgio Valoti wrote:


On Lunedl, giu 30, 2003, at 15:26 US/Pacific, B. Shank wrote:

I assume you're referring to compound keys. If so, see http://developer.apple.com/documentation/WebObjects/ Enterprise_Objects/Saving/chapter_8_section_8.html#//apple_ref/doc/ uid/DontLinkBookID_460-DontLinkChapterID_8-BADJEBIB

Brent

On Monday, June 30, 2003, at 2:16PM, Ricardo Strausz wrote:

Hola!
does EOF supports multiple PKs generation?

Let me be more specific: in a one-to-many relation (say Invoices->>Details) I want to give Details a double PK; the invoices PK and a consecutive number.

Can EOF (in its lateest version) do this for me?

Gracias,


EOF cannot generate compound primary keys, nor a RDBMS can for that matter. Compound PK are usually composed by two or more foreign keys, so they cannot be automatically generated. However, an auto-generated primary key can be used for performance reasons, but some more constraints should be enforced.
In your specific case, the Details PK is enough to uniquely identify a record: adding the Invoice PK brings no advantages.

In fact, it does; this brings back an old discussion on the uses of PKs. There are people who stiks in the paradigm of using "non-sense" PKs, but in the database I am modeling, the PKs have meaning to the users (invoice number, and item in the example below) so the object is unique up to these constrains (e.g., the third item in the invoice number 1234).

Well, a PK can or cannot have a meaning to the user, I agree. My position on this issue stems from the fact that when you a have meaningful PK, you have to be prepared to deal with the possibility that a PK could change, precisely because the PK has a "business meaning". That's not necessarily bad, but it can be annoying, so I prefer to avoid this, if I can. Obviously using a synthetic PK in your case, leads to the another issue, namely that you have to enforce a constraint about the uniqueness of the combination of the Invoice PK + the number of the Item and that's not easy with EOF.


HTH

--
Giorgio Valoti
-------------
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Mixed PKs?
      • From: Chuck Hill <email@hidden>
References: 
 >Re: Mixed PKs? (From: Ricardo Strausz <email@hidden>)

  • Prev by Date: Re: Changing from openbaseSql to MySql
  • Next by Date: Re: Changing from openbaseSql to MySql
  • Previous by thread: Re: Mixed PKs?
  • Next by thread: Re: Mixed PKs?
  • Index(es):
    • Date
    • Thread