Re: "The WO way"
Re: "The WO way"
- Subject: Re: "The WO way"
- From: Christian Brunschen <email@hidden>
- Date: Sun, 9 Oct 2005 10:55:12 +0100
On 9 Oct 2005, at 10:08, Mark Wardle wrote:
Hi all. Hope you don't mind me writing again! I'm trying to work
out the "right way" of handling a data model.
I have a number of "User"s modelled. Each user can have any number
of "Events" linked in a one-to-many join. Each event has a number
of attributes, all linked one-to-one to other tables - for example
"typeOfPatientFK". These attribute tables are generally static, and
do not ever change. Type of patient may only have two or three
records - such as "New" and "Follow-up".
Data entry and manipulation is simple given WO's way of abstracting
everything. It works really well. Originally, I had a two way
relationship from "TypeOfPatient" to the "Event", but after reading
things about the inefficiency of this and the risk of pulling in
*all* events related to that attribute, I thought about deleting
the reverse relationship.
However, I will also need to generate reports. I will need to
display all events related to a "TypeOfPatient" - for a particular
user. If I left in the reverse relationship, I'd get all related
events but for all users, not just the user in question.
Therefore, my preference would be to remove the inverse
relationship from TypeOfPatient to event, and instead use a
FetchSpecification. Thus, I pull out all events related to both a
particular User and a particular TypeOfPatient. However, to create
that, I have to determine the required primary and foreign keys -
which seems to me to be a rather non-WebObjects way of doing
things. Am I being stupid, or is there a "better way"?
In my opinion, you are on the right track with getting rid of the
inverse relationship.
In order to be able to fetch all Events for a given PatientType, or
for a given PatientType and User, you would write a static method in
the Event class which performs a fetch, with a Fetch Specification
either created in code or pre-defined in the EOModel.
Something like (code typed in email):
public NSArray eventsWithPatientTypeAndUser(EOEditingContext ec,
PatientType pt, User u) {
EOQualifier qual = EOQualifier.qualifierWithQualifierFormat
("patientType =%@ and user = %@", new NSArray(new Object[]{ pt,u }));
return ec.objectsWithFetchSpecification(new
EOFetchSpecification("Event", qual, null);
}
Many thanks,
Best wishes,
Mark
// Christian Brunschen
_______________________________________________
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
References: | |
| >"The WO way" (From: Mark Wardle <email@hidden>) |