views:

35

answers:

1

Suppose I have the following data model:

Entity Person
Attribute name String
Attribute personType String
Attribute dailyRecords

Entity CarpenterDailyRecord
Attribute numberOfNailsHammered Int
Attribute picNameOfFinishedCabinet String

Entity WindowWasherDailyRecord
Attribute nameOfBuildingWashed String
Attribute numberOfWindowsWashed Int

I would like to establish a to-many relationship between the Person.dailyRecords and 1 of the daily record entities (which changes depending on the person type). Of course, i could create a CarpenterPerson and WindowWasher entity which each points to it's unique daily record structure, but i have to group people together in my app somehow.

so if i do a Group Entity:

Entity Group Attribute people array

i'm still stuck. how do i point to multiple & different Person entities?

There must be an obvious answer, it's just i'm so new to all of this. thanks!

A: 

Create a parent (DailyRecord) entity that handles the relationship (Person <-->> DailyRecord). [CarpenterDailyRecord|WindowWasherDailyRecord] then inherits from DailyRecord.

The risk with this, however, is that all of the children (WindowWasherDailyRecord, CarpenterDailyRecord) will be in one table in the underlying sqlite structure and therefore can cause a performance impact. This is not a reason to avoid inheritance, just something to be aware of while designing your data model.

Marcus S. Zarra
thank you Marcus. there could be enough overlap in the data represented in the different record types that core data won't have to create too many unique columns. i'll have to investigate. i assume DailyRecord entity could be abstract? I'll read further on this topic but i think i've got the gist. thanks again!
carotene
Yes, sorry that was not clear, the DailyRecord entity would be abstract. BTW, don't forget to accept the answer you find as correct.
Marcus S. Zarra

related questions