user4951
user4951

Reputation: 33080

Multiple Relationship In Core Data to Entities of the Same Type

Say I have a business class

Business class has 3 relationships

menus are menus brochures are brochures images are images

They are all related to an image entity. Image entity has a business relationship which points to the business owning the menus, brochures, and images respectively.

What would be the inverse relationship of the business relationship then? Menus? Brochures? or Images?

Upvotes: 0

Views: 295

Answers (1)

Amy Worrall
Amy Worrall

Reputation: 16337

I think each relationship needs its own inverse, for data integrity reasons. So if you have menus, brochures and images, you need three inverses: businessForMenu, businessForBrochure, businessForImage.

If you need to be able to access the aggregate of those three things, you could then model the business relationship from image as a fetched property, selecting on Business, with the predicate

ANY menus == "$FETCH_SOURCE" OR ANY brochures == "$FETCH_SOURCE" OR ANY images == "$FETCH_SOURCE"

Upvotes: 1

Related Questions