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.
这导致了Tag实体的创建。我的问题是如何建立关系模型?许多帖子与许多标签相关联。每个标签可以与一个或多个帖子相关联。
Any ideas? Do I need a mapping table, or does Core Data handle this? Thanks.
有任何想法吗?我需要映射表,还是核心数据处理这个?谢谢。
1 个解决方案
#1
7
Core Data supports many-to-many relationships so this shouldn't be a problem as long as you define the model correctly. For instance:
核心数据支持多对多关系,因此只要您正确定义模型,这不应成为问题。例如:
#1
7
Core Data supports many-to-many relationships so this shouldn't be a problem as long as you define the model correctly. For instance:
核心数据支持多对多关系,因此只要您正确定义模型,这不应成为问题。例如: