Dealing with relationships and inheritance
Dealing with relationships and inheritance
- Subject: Dealing with relationships and inheritance
- From: Charles Koppelman <email@hidden>
- Date: Thu, 07 Feb 2008 15:32:09 -0500
- Thread-topic: Dealing with relationships and inheritance
We've been using single-table inheritance here for quite a while.
Let's start with an example:
A person can send an email or fax. They share plenty of fields and plenty
of methods, but there is a bit of divergence.
So we have something like...
Person ->> Message where Message can be either EmailMessage (MESSAGE_TYPE 1)
or FaxMessage (2).
I notice that when this method is traversed, it creates two SQL statements
for each Message like:
SELECT ... FROM MESSAGE WHERE MESSAGE_ID = 1234 AND MESSAGE_TYPE = 1;
SELECT ... FROM MESSAGE WHERE MESSAGE_ID = 1234 AND MESSAGE_TYPE = 2;
Is this the default behavior? If so, then it seems a bit of a waste to me -
why not say, either...WHERE MESSAGE_ID = 1234; or ...WHERE MESSAGE_ID = 1234
AND MESSAGE_TYPE in (1, 2);
By creating worthless calls that will return 0 records, we're needlessly
slowing our app.
Any advice?
Thanks, and happy Year of the Rat!
Charles Koppelman
Programmer
Youth For Understanding, USA
_______________________________________________
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