Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set primary key and foreign key in core data?

Tags:

iphone

I am using core data for my application. I don't have exact idea how can I set primary key and foreign key relationship. And how to insert data accordingly.

like image 701
Javal Nanda Avatar asked Nov 02 '10 05:11

Javal Nanda


1 Answers

CoreData isn't a Database. It's an object persistence layer. There is no concept of primary keys or foreign keys in CoreData.

If you want to establish a relationship between two entities. You'll define a relationship, CoreData takes care of how that relationship is stored.

Select an entity, use plus button at the bottom of the entities attributes list, select add relationship, select the destination entity from the dropdown.

Select the destination entity and define an inverse relationship in the same way.

like image 189
tonklon Avatar answered Oct 18 '22 21:10

tonklon