0

I have a problem where I want to search for data in an application's database managed by Core Data. The problem is, that the key I would be using to query the database may have several similar ways of being written. For example, I want to access same data element with name "tomato" with the key "tomato" or "tomatoes". All other data fields would be the same. Does Core Data offer any built-in functionality to create aliases for a key so that a single element can be accessed by multiple keys?

I tried adding duplicate elements that only different by the "name" attribute, but I do not want to do this for every entry as it would require my database to use at least twice as much space.

KhanKhuu
  • 177
  • 11
  • https://stackoverflow.com/questions/35434861/save-multiple-values-per-key-in-coredata – Harish Mar 19 '20 at 20:28
  • 2
    The first, very important, thing to understand about Core Data, is that it isn't a database. It is an object persistence system. So don't try and apply database concepts. Maybe you need a different data store that is a database – Paulw11 Mar 19 '20 at 20:28
  • I can't quite imagine the code you would write to select objects such that aliased names would be necessary. However, if you need it, you'll probably need to resolve the aliases in an entity method, such as `canonicalKey(for alias: String) -> String`. – Phillip Mills Mar 19 '20 at 21:01

0 Answers0