I have a question regarding the way you create relationships in Core Data.
I will explain with an example:
Let’s say I have 3 entities. Motor, Pump and Warning.
Motor and Pump can send warnings.
The Warning entity will store all the warnings from Motor and Pump.
So the question is… Is it really necessary to create so many relationships in Warning for Motor and Pump? When I want to add another entity that can send warnings, I will need another relationship.
Wouldn’t this be bad design?
Hope I’m understandable.
Thanks.
Yes, this is normal. A better, more structured approach is to have a base entity for Motor and Pump, let’s call it Component. This Component entity has the relationship with Warnings and the warning entity has an inverse relationship to Component.
You then set your Motor and Pump to be descendants of the Component entity and everything is good. One single relationship / inverse relationship between Component and Warning.