CoreData Entity Inheritance
Consider that i have two entities with following relationship:
Entity A <-->> Entity B (one-to-many and inverse)
Now consider that i have another entity Entity C that contains all the attributes of Entity B and some others, with following relationship:
Entity A <-->> Entity C (one-to-many and inverse)
Now i can improve the architecture by making Entity B the parent of Entity C.
Entity B
^
|
Entity C
Now, my question is, will the 开发者_高级运维attribute(s) AS WELL AS the relationship(s) be inherited by Entity C? Meaning, do i still need to keep the following relationship (separately)?:
Entity A <-->> Entity C
Also, i couldn't find a good example for entity inheritance in Apple documentation for Core Data. Does anyone know of an online resource that explains this, with example (preferably)?
Yes, attributes and relationships and everything else will be inherited. Be careful though, child entities like that will share the same table in sqlite with the parent entity. So if you have C inheriting from B, then a table will be created in sqlite that has the properties for both B and C which the obvious voids in the table. This is not too much of an issue with a simple inheritance like this but if you decide to get "creative" you can end up with your entire model in one table.
Now, my question is, will the attribute(s) AS WELL AS the relationship(s) be inherited by Entity C? Meaning, do i still need to keep the following relationship (separately)?:
Yes all attributes and relationships are inherited. Only little documentation is available at ADC
精彩评论