I have a database design that's normalized well enough, but now I need to add a new table (entity, since I'm actually using Core Data) and I'm running into some issues.
Landscape has many Assessment
Assessment has one AssessmentType
AssessmentTree has one Assessment
AssessmentTree has one each of 12 other entities, omitted for space.
Now, I'm adding a Photo entity, which can be associated with ANY of the above entities. I need to have some sort of relationship in place such that I can grab only the Photos related to an AssessmentTree, for example, or perhaps an Assessment, which would be a superset of the Photos related to an AssessmentTree.
(I feel I may not have done a great job explaining the situation so let me know if I can clarify in some way.)
Possible solutions I've considered, none of which are satisfying:
- Create references to every other object from within the Photo entity. Nil references would then mean the Photo was not a part of that set.
- Create a new entity, PhotoRelations, that would hold a reference to the Photo and a reference to one of the objects it's attached. The problem is that while I could easily do this with an SQL system, I can't think of how to translate it into CoreData.
Any help would be appreciated!