Currently I need to set up a database that uses the following structure.
- Item 1
- Object A
- Stuff A1
- Stuff A2
- Stuff A3
- Object B
- Stuff B1
- Object A
My first thought was to create 3 entities, one for “Item”, “Object”, and “Stuff”, then have an array in each.
So each “Item” would have an array containing the “objects”, and each object with an array of “stuff.”
Would this be a good approach? If not, what would be a more correct and efficient way of accomplishing the same task?
In theese situations, when you have 2 entities and you want to have a relation between them, you should try out CoreData’s relationships. In this case you should use to-many relationship.
PS: Don’t forget to select your relationship delete rule! 🙂