Re: Core Data SQL store looses data that XML store does not
Re: Core Data SQL store looses data that XML store does not
- Subject: Re: Core Data SQL store looses data that XML store does not
- From: Jack Nutting <email@hidden>
- Date: Wed, 17 Aug 2005 21:55:37 +0200
On 8/17/05, Terrence Talbot <email@hidden> wrote:
> I just happen to have a special case where I have an object that will
> have some X in list A and some X in list B and always be the owner
> (the inverse of the relationship) for all objects in either list
> until they are deleted from the context. Is a separate List object
> really the best way to go?
OK, that is a special case. Hmmm. How about this:
THING_WITH_LISTS
aListXs ->> (X)
bListXs ->> (X)
X
aListOwner -> (THING_WITH_LISTS)
bListOwner -> (THING_WITH_LISTS)
myOwner -> (THING_WITH_LISTS)
So, you create these two sets of inverse relationships
THING_WITH_LISTS.aListXs <->> X.aListOwner
THING_WITH_LISTS.bListXs <->> X.bListOwner
but those are bidirectional ONLY to satisfy the requirement that they
must be (in order to not mess up the data store when moving from xml
to sqlite). What you must do, in code, is to check whenever either
X.aListOwner or X.bListOwner is set (which CoreData will do for you
whenever you attach an X to a bListXs or aListXs relationship), and at
that time manually set X.myOwner to the same. Then you can be sure
that traversing X.myOwner will always get you back to the right owner.
I still feel like there ought to be a better way to model this, but
it's not quite clear to me yet.
--
// jack
// http://www.nuthole.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden