Mike Zhu
Mike Zhu
1,840 Points

What is the inverse relationship in Core Data?

I am new to Core Data in iOS. I would like to know the difference between "inverse" relationship and "No inverse" relationship between difference entities.

1 Answer

Greg Kaleka
Greg Kaleka
39,004 Points

Hi Mike,

To the docs!

This is a concept that doesn't only apply to CoreData, but rather extends to databases in general. Essentially, the difference is that "inverse" relationships are ones that go in both directions. For example a teacher has many students, and each student has that teacher.

A unidirectional relationship (or "no inverse" as you put it) is one that goes only one way. It's harder to come up with an easy to grasp example, and it's generally not a good idea to model your data this way, since you will end up with a lot of potential issues you'll need to keep track of.

Check out more details in the docs I linked to above.