开发者

Best Practice for ensuring CoreData entities are unique based on entity attributes

What I'm t开发者_StackOverflow社区rying to do is ensure entities in my graph are unique. For example, no two users should have the same social security number.

The two solutions I've seen out there are:

1) index your entities and search for matching entities using predicates prior to creating new objects

2) Create an in-memory dictionary for each entity unique attribute.

iConfess: I'm coming from a relational database world. I'm user to primary keys.

What is the best practice for what I'm trying to do.


I'd go with choice 1: "index your entities and search for matching entities using predicates prior to creating new object". It just seems to me that going with an in-memory dictionary requires that you would be (I'm assuming) duplicating content that would need to be maintained, thus creating opportunities for error, and has the potential of bloating to something larger than originally expected.

There could be a speed issue—querying indexed core data vs. querying a dictionary—but that could be so niggling as to be moot as I've had no issues with Core Data's speed so far.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜