CoreData Father, mother children relationship, Can a CoreData subclass have a same relationship with two subclasses?

时间:2016-10-15 16:57:45

标签: ios objective-c xcode core-data

I am so struck with this problem

I have a "Person" Coredata Subclass,

Obviously a Person has a father(Person), mother(Person),Spouse(Person) and Children(List of Persons)

(represented in terms of relationship)

If a person is one of the children of his father he is one of the children of his mother two.

So "children" has to be related to Mother and Father.

I cant do that in Core data, Am I missing anything? Is there a way to solve this problem?

1 个答案:

答案 0 :(得分:3)

如果你正在使用CoreData,你应该知道它是SQLite的说唱歌手,所以你需要像在SQL中那样建立你的关系。 人“孩子”是父亲和母亲的n:1实现。 为实例MotherToChild建模一个新实体,您可以在其中执行映射,如SQL中的规范化。