Subject RE: [firebird-support] Correct join design
Author Rick DeBay
In one case it takes 7% longer with the unused table in the join, and of
course the plan is bigger. From a correctness stand-point, is there a
down-side to not including the unused table?

-----Original Message-----
From: Rick DeBay
Sent: Friday, January 21, 2005 10:53 AM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Correct join design


Given this relationship

AccountData1 --FK--> Account <--FK-- AccountData2

And the requirement to retrieve data from AccountData1 and AccountData2
(nothing is required from Account), what is the correct join?

AccountData1 join Account on AccountData1.fk = Account.id join
AccountData2 on AccountData2.fk = Account.id

AccountData1 join AccountData2 on AccountData1.fk = AccountData2.fk

The second version saves a join by cutting out the join to Account, as
we don't need any data from it. But this leaves out the element that
defines their relationship, which may not be desirable from a
maintenance/documentation point of view.
What I'm looking for is not what works or what is legal syntax, but what
is the pedantic answer, and how or whether it will affect performance.

Rick DeBay
Senior Software Developer
RxStrategies.net



Yahoo! Groups Links