Reputation: 9042
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.
Upvotes: 1
Views: 2227
Reputation: 2480
Core Data supports many-to-many relationships so this shouldn't be a problem as long as you define the model correctly. For instance:
Upvotes: 7