I am new to Core Data and trying to think of the simplest and / or most performant way to implement a tags feature for ite开发者_开发问答ms in Core Data. I am still wrapping my head around the fundamental differences between core data and the sql server I am used to.
Has anyone done this? Or have any suggestions of a solid implementation for this?
I would assume I have 2 options:
A separate entity for Tags, each containing a tagName and a relationship to the items that that tagName applies to.
Store tags in a attribute on the item itself and search those.
Seems like option 1 above would be the best for solution.
Yes, you want to do 1, I guess with a many-to-many relation since an item could have many tags and a tag could belong to many items. It would otherwise be great to store it in attributes, but Core Data does not support composite attributes (e.g NSDictionary, NSArray), it only supports primitive attributes (integer, text etc).
精彩评论