Group1 shouldn’t have all the properties of the PeopleProfile it should only have the id property of the person that’s saved, so it’s actually a list of UUID. When you retrieve the data, you connect the data together (called joining) from the PeopleProfile
This is what’s called a foreign key relationship in relational databases.
Your entities should look like this:
-
PeopleProfile: stores all the people-
idasUUID -
nameasString
-
-
Groups: stores all the groups and what people are in that group-
GroupNumberasInt, this shouldn’t be an “id” because id usually means something that’s unique, which in your example it’s just denoting that someone is in group 1 -
PeopleProfileIdasUUID, this is theUUIDof thePeopleProfile
-
When you fetch the data, you first fetch everyone from Groups with a specific GroupNumber, and then given that you have all the ids of the people. Next loop through those people and fetch all their information. (There might be a way to combine these, but I’m not sure what it is in CoreData). Haha I know what it would be writing normal SQL (which is used with relational databases)