Re: many-to-many relationships and object design
Re: many-to-many relationships and object design
- Subject: Re: many-to-many relationships and object design
- From: mmalcolm crawford <email@hidden>
- Date: Thu, 17 Jun 2004 22:31:45 -0700
On Jun 17, 2004, at 10:01 PM, Todd Ransom wrote:
Don't I run a risk of the data becoming out os sync if I do this?
No: my point was precisely to ensure that data does not become out of
sync. If you don't consider the inverse relationships, you run that
risk.
For example, I add an actor object to the actors array in a scene
object. Later, I update a property of the actor (actors have a
"notes" property where I can take notes about them). Do I have two
different actor objects, or do I have two references to the same
actor?
You should have two references to the same actor,
And what about when I serialize/unserialize using
encodeWithCoder:/initWithCoder: ? I don't see how my scene object
could get a reference to an existing actor object during
unserialization. That's why I think I need a method for resolving IDs
to objects, so I can serialize the IDs and unserialize as objects.
Provided that you deal with just a single object graph,
encodeWithCoder:/initWithCoder: will do the right thing. If you deal
with multiple graphs, then you do run the risk of data getting out of
sync and it's likely you'll need to associate a "global ID" with each
object to assure uniqueness. Again, this is discussed in the
WebObjects documentation.
mmalc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.