什么是设计这个核心数据数据库的好方法? [英] What would be a good way to design this core data database?

查看:114
本文介绍了什么是设计这个核心数据数据库的好方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个使用核心数据的iphone应用程序。数据包括大量的人员。每个人都有一定的属性是相同的。名字,姓氏,年龄和更多。然后这些人将被分成几类。我拥有不同类别的人的问题会有不同的属性。



例如



人A将在类别A中,并且具有属性a,b,c

人B将在类别B中,并将拥有b,c,d



人C将在类别b和c,并具有属性c,d,e



我想要有
Entity Person



实体类别



实体人物属性将存储不适用于此人的所有属性,只会为null。



在代码中,我将知道这个人是否是类别a他只有属性a,b,c



这将是一个好的设计

解决方案



在没有其他设计考虑的情况下,我将使用一个Person实体,其中包含该类别的属性以及属性a,b,c,d和e。



如果你想进一步,要求不支持的属性是nil,我会看看属性验证。实现 validateA:error:根据对象的类别返回YES或NO,等等。


I am working on an iphone app that uses core data. The data includes large list of people. Each person will have certain attribues which are the same. First Name, Last Name, age and few more. Then these people will be divided into categories. The problem that i am having people who are in different categories will have different attributes.

For example

Person A will be in category A and will have attributes a,b,c

Person B will be in category B and will have attribues b,c,d

Person C will be in category b and c and will have attributes c,d,e

I am thinking to have Entity Person

Entity Category

Entity personattributes which will store attributes for all the once that do not apply to this person will just be null.

In the code i will know if the person is category a he will only have attributes a,b,c

Will that be a good design or i would need a separate attributes entity for each category

Thanks in advance!

解决方案

In the absence of other design considerations, I'd use a single Person entity, with an attribute for the category, and attributes a, b, c, d, and e.

If you want to go a little further and require unsupported attributes be nil, I would look at attribute validation. Implement validateA:error: to return YES or NO based on the object's category, and so on.

这篇关于什么是设计这个核心数据数据库的好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆