Modern, Efficient Core Data | raywenderlich.com

Hi @atetlaw, actually I need to insert more 30000 records.

I can’t see how the relationships work - how do you know which radical belongs to which Kanji?

Radical Entity has an attribute called ‘radical’ that contain the character.
Kanji Entity has an attribute called ‘radical’ that contain the character.

but you can you the tipica method with attribute id and id_radical, if for you is better.

That’s sounding tricky to me, and now I’m wondering if batch insert requests are really suitable to your situation?

This is a great question. but it’s very strange that there isn’t a way to set quickly the relationship.
let me explain:my problem isn’t how to set the relationship. Because if read the code that I posted in this post NSBatchInsertRequest and Relationship
i do what you suggest: first the inserting and after the relationship.
My problem is the timing. as I already said the inserting without set relationship lasts only 5 seconds. The setting of relationship 35 seconds. to do this I loops on all radical and look for the kanji object inside the array of object and set the relationship. I know that the filter function has a O(n) of time complexity. so is this the problem? is there an alternative to filter function? maybe I have use the FetchRequest?

I understand that thinking of a database that you don’t have can be complicated. So try to think of a database made up of different entities related to each other (It doesn’t have to be big. 3, 4 entities are fine too). and imagine that the database is populated with 30-40000 records. How would you enter all those records and how would you set up relationships in the shortest time possible? Keep in mind that the user has to wait for the download and database population to finish before using the app (and that’s where the difficulty lies. Time.)
How would you do it?

Thank you very much for your patience