Subset of relationship
Subset of relationship
- Subject: Subset of relationship
- From: Emerson <email@hidden>
- Date: Tue, 09 Aug 2005 17:44:37 -0300
Hello friends,
I have a very basic question, mainly because I've just recently started
developing in WO. Although I have some ideas, I'd like to get some
feedback in order to use best practices right from the beginning.
Consider a model where you have a number of entities. In that model,
User records users and Message records messages sent and drafts saved by
users. I decided not to split messages sent and drafts saved in two
different entities because several properties and relationships would
have been duplicated; moreover, since a draft can become a message, it
sounded inefficient to me having to create a new message and literally
copy each and every property/relationship whenever a draft was sent. It
sounds like just a state change.
Nothing new so far.
It happens that I would like to browse either all messages sent or all
drafts saved by a user, but not both at the some time. EOF gives me a
NSArray of Messages, containing both messages sent and drafts saved,
resulting from the relationship with the entity Message.
What's the most recommended way of getting a NSArray with only the
drafts saved or messages sent?
1. using an in-memory operation with java.util.Enumerator to split
messages sent and drafts saved (by looking at the value of a "state"
property); this approach sounds inefficient, since all messages are
fetched and comparisons are made in memory; databases are probably
better at that job. By the way, I feel this alternative should use
something like NSKeyValeCoding and NSKeyValueCodingAdditions instead of
enum, but I just can't figure out how.
2. creating a fetch specification in the entity Message which returns
all drafts for a given userid. In the class User, a method named
draftsFS could be defined so that it creates a new fetch specification
by assigning the userid obtained with EOUtilities to the raw fetch
specification defined in the entity Message; the application would be in
charge of doing the fetch. This approach just "forgets" the default
relationship.
3. the model should be redesigned so Messages and Drafts are set apart.
Since I'm having problems with such a basic issue, I know I must be
doing something really wrong and that's why I decided to request your
opinions.
thanks in advance,
Emerson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden