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.