Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

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,016 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.

Cheers,

-Greg