Re: Traversing keys or EOEntities
Re: Traversing keys or EOEntities
- Subject: Re: Traversing keys or EOEntities
- From: Art Isbell <email@hidden>
- Date: Wed, 12 Feb 2003 15:15:46 -1000
On Wednesday, February 12, 2003, at 03:04 PM, Jonathan Fleming wrote:
Having read your piece I can see that I don't need the mandatory
relationship because a tbClientData does not have to exsist with a
tbClient and so it can or should be able to save without reference to
a tbClient.
My logic was that since there is only one tbClientData object that
will ever belong to a tbClient then a oneToOne relationship would
surfice, however, between you highlighting that i was running into a
potentially difficult situation with this oneToOne relationship and
Jonathan Rochkind noting that he does his level best to steer clear of
"owns destination" options in these situations, I think i'll avoid
oneToOne relationships as much as is possible. they're begining to
sound like a nightmere.
You've arrived at two bad conclusions. To-one relationships should be
used when no more than one object can be related to another object.
The only exception is when the foreign key of a to-one relationship is
also the primary key, and the relationship is optional. In this case,
modeling this as a to-many relationship is necessary.
Owns Destination relationships work fine if what this property implies
is true with the real data.
In both cases, troubles arise when the model doesn't reflect the
behavior of the real data. But don't avoid using these valuable
modeling features just because they aren't suitable in some cases.
I'm going to change the EOModel to produce tbClient with a oneToMany>>
relationship to tbClientData, therefore tbClientData with hava a
<ToOne relationship back.
That should work. But don't make both relationships class properties
unless you really need to traverse both relationships in your code.
Doing so will result in additional database accesses that would only be
necessary if you really traverse both relationships.
Art
http://homepage.mac.com/aisbell/
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.