1
votes

I am currently working on producing the data model for my application and it is extremely important I get it designed correctly before implementation can begin otherwise it will be a huge problem.

My situation is, I have an entity which is a Post. Each post has many Tags associated with it. Initially, I wanted to store an array of tags within each Post, but then I realised this would not be normalised and there would be repetitive data. As each post may have tags in common with each other.

This led to the creation of the Tag entity. My issue is how do I model the relationship? Many posts are associated with many tags. Each tag may be associated with one or more posts.

Any ideas? Do I need a mapping table, or does Core Data handle this? Thanks.

1

1 Answers

7
votes

Core Data supports many-to-many relationships so this shouldn't be a problem as long as you define the model correctly. For instance:

enter image description hereenter image description hereenter image description here