Reputation: 7484
can i have an entity have a to-many relationship to itself?
getting a group list from my server, and it can have n number of names and n number of levels. at the top level, lets say i have:
Scott
Jason
Scott and Jason both have n number of employees under them. Scott has
Bryan
Matt
Bryan and Matt both have n number of employees under them
Jill
Lisa
Jill and Lisa both have n Number of employees under them.
sortive like:
but with n subGroups.
my list can have n levels. it needs to be dynamic.
can i boil it down to:
can i just have one entity, Person, that has many-to-many relationship to itself?
Upvotes: 0
Views: 93
Reputation: 539815
Yes, an entity can have a many-to-many relationship to itself. You have to define two to-many relationships, e.g.
members
as to-many relationship from Person
to Person
,leaders
as to-many relationship from Person
to Person
,and set both as inverse relationships of each other.
See also Many-to-Many Relationships in the "Core Data Programming Guide".
Upvotes: 2