user676842
user676842

Reputation: 127

Question about inverse releationship in Core Data

HI

I am just starting to learn Core Data and one part that confuses me is the inverse relationship. Lets say that I have a entitiy named Photo and one enitity named Photograph, just as in the Stanford course. A photograph has a one to many relationship to photo, and one photo belongs to one photograph.

My question is (I know SQL) is what are the inverse relationships I have to make? This probably has to do with primary/foreign key however I do not understand what inverse relationship does?

Thanks for your time:=)

Upvotes: 0

Views: 220

Answers (1)

Alex Reynolds
Alex Reynolds

Reputation: 96966

An inverse relationship maintains data integrity when changes are made to instances of an entity:

You should typically model relationships in both directions, and specify the inverse relationships appropriately. Core Data uses this information to ensure the consistency of the object graph if a change is made (see “Manipulating Relationships and Object Graph Integrity”). For a discussion of some of the reasons why you might want to not model a relationship in both directions, and some of the problems that might arise if you don’t, see “Unidirectional Relationships.”

Upvotes: 1

Related Questions