IPhone CoreData: How should I relate many child entities to thier parents
Posted
by Robert
on Stack Overflow
See other posts from Stack Overflow
or by Robert
Published on 2010-04-27T15:13:34Z
Indexed on
2010/04/28
8:33 UTC
Read the original article
Hit count: 211
I am trying to import data from a database that uses primary key / forign key relations to a core data database in Xcode.
I have code that creates hundreds of child entities in a managed object context:
Each child has an ID that corresponds to a parent.
child1 parentID = 3
child2 parentID = 17
child3 parentID = 17
...
childn parentID = 5
I now need to relate each child to its parent. The parents are all stored in persistent memory.
My first thought was to preform a fetch for each child to get its parent. However, I think this would be slow.
Am I correct? How should I do this instead?
© Stack Overflow or respective owner