Database design problem - keeping relationships at a minimum?

The way that Core Data is designed to handle this problem is through entity inheritance In theory, you would handle this just the way you would with non-Core Data objects defined with subclasses. You would define an abstract parent entity that links to a concrete photo entity. Then you would have all the entities that need a photo inherit from that parent entity However, owing to an implementation detail with SQL stores, all the child entities of a parent entity in any graph end up in the same SQL table on disk.

This can degrade fetch performance because all the instance of all sub-entities stored in a table have to be searched even if your just fetching one entity It's a pain. I keep hoping they will refractor that limitation out You could test the entity inheritance with test data and see if it is a problem or not for your particular implementation. If you have only a few thousand sub entities that fetch on simple attributes (strings, numbers, dates etc), then you may be able to use entity inheritance without any significant performance hit.

The way that Core Data is designed to handle this problem is through entity inheritance. In theory, you would handle this just the way you would with non-Core Data objects defined with subclasses. You would define an abstract parent entity that links to a concrete photo entity.

Then you would have all the entities that need a photo inherit from that parent entity. However, owing to an implementation detail with SQL stores, all the child entities of a parent entity in any graph end up in the same SQL table on disk. This can degrade fetch performance because all the instance of all sub-entities stored in a table have to be searched even if your just fetching one entity.It's a pain.

I keep hoping they will refractor that limitation out. You could test the entity inheritance with test data and see if it is a problem or not for your particular implementation. If you have only a few thousand sub entities that fetch on simple attributes (strings, numbers, dates etc), then you may be able to use entity inheritance without any significant performance hit.

I've implemented this and it does mostly what I need, but I'd like to be able to associate multiple photos for each entity, which seems difficult with this method. Suggestions? – Evan Cordell Aug 9 '10 at 16:10 Change to photo relationship in the parent to a to-many.

That will let you associate an arbitrary number of photos with each instances of a sub-entity. – TechZen Aug 9 '10 at 19:44 That works beautifully, thanks. – Evan Cordell Aug 9 '10 at 20:14.

Since Photo is a child then I would go with your first option and create a link to each entity. However, what do you plan on storing in Photo? If it is just the binary data then I would reconsider it and store a filePath to the image on disk instead.

Storing binary data in Core Data is less than ideal. Then if you get down to just storing the file path you may be able to skip the entity entirely and just store the filePath in the parent object(s).

What you could do is create a relation table like this: linkedId | photoId | LinkType LinkType can be any of the above listed as an integer 1-N.

This doesn't seem different from my second idea, and requires adding an id field to every other entity, as well as a bunch of extra code to keep track of said ids. – Evan Cordell Aug 6 '10 at 19:35.

The way that Core Data is designed to handle this problem is through entity inheritance. In theory, you would handle this just the way you would with non-Core Data objects defined with subclasses. You would define an abstract parent entity that links to a concrete photo entity.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions