Re: Unique items in Core Data models
Re: Unique items in Core Data models
- Subject: Re: Unique items in Core Data models
- From: Sam Stigler <email@hidden>
- Date: Tue, 15 May 2007 18:54:18 +1000
I'm sorry; I should've known better about the SQLite and primary key
statements.
Sam
On May 15, 2007, at 4:05 PM, mmalc crawford wrote:
On May 14, 2007, at 6:50 PM, Sam Stigler wrote:
I just found the section on "Faulting and Uniquing" in Apple's
Core Data Programming Guide; that looks like it might have what
you're looking for.
No, that explains how Core Data ensures that, for any given managed
object context there is no more than one managed object
corresponding to any given record in the persistent store.
That's a good question.... you'd hope so, considering that it's
based on SQLite....
Core Data is *not* "based on SQLite". SQLite is one of the
persistent store formats supported by Core Data (see <http://
developer.apple.com/documentation/Cocoa/Conceptual/CoreData/
Articles/cdPersistentStores.html> -- see also <http://
developer.apple.com/documentation/Cocoa/Conceptual/CoreData/
Articles/cdBasics.html>).
You might have more luck in a search for this if you use the term
"key" instead of "unique item" -- in relational database terms,
what you want is for the title to be the key. (Seehttp://
en.wikipedia.org/wiki/Relational_database#Keys.)
No! Absolutely not. Primary key and unique value are different
things. Something may not be a primary key and yet need to be
unique. Typically a primary key should be a simple integer value.
Core Data does not provide a mechanism to unique attribute values.
Uniquing attributes is typically an expensive and sometimes
difficult thing to do. The basic way is to execute a fetch prior
to assigning a value (the fetch predicate being
<nameOfUniqueAttribute> == newValue; you want the count of the
returned array to be 0).
mmalc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden