Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Number of joins in the query
Since the primary key/foregin key can be composite, there can be more than
n-1 join conditions, but there will be only n-1 joins.
e.g. A's primary key is col1 and col2 referred by B's col1 and col2
in this case you will only have 1 join, between A and B, but 2 join conditions
A.col1 = B.col1 and A.col2 = B.col2
but in no case you should join A to B, B to C and then A to C again. If you need to do that, then go one step back and look at the design.
Regards
Naveen
-----Original Message-----
Sent: Thursday, February 27, 2003 11:36 PM
To: Multiple recipients of list ORACLE-L
If you are joining 'n' number of tables, you should have a minimum of 'n-1' joining conditions, otherwise it might result in cartesian product.
Sunil Nookala
Dell Corp.
-----Original Message-----
Sent: Thursday, February 27, 2003 10:29 AM
To: Multiple recipients of list ORACLE-L
Two!
PK on stn_rstcn_to_frm?
T'would be clearer if you presented your problem as tables a, b, c, rather than getting us to struggle through all these stns...
peter
-----Original Message-----
[mailto:Ranganath.Krishnaswamy_at_blr.hpsglobal.com]
Sent: 27 February 2003 14:59
To: Multiple recipients of list ORACLE-L
Dear List,
I have a basic doubt about the number of joins I should have. Say, I have three tables by name station, station_restriction and stn_rstcn_to_frm with the following structure:
Station Station_restriction stn_rstcn_to_frm ---------- ---------------------------- ------------------------- stn_key(PK) stn_rstcn_key(PK) stn_rstcn_key(FK) station_code stn_key(FK) stn_key(FK) station_name restricted_position country If I have to select data from all the three tables should I have twojoins or three joins?
If I have two joins, I would have
Station.stn_key=Station_restriction.stn_key and Station_restriction.stn_rstcn_key = stn_rstcn_to_frm.stn_rstcn_key.
If I have three joins I would have
Station.stn_key=Station_restriction.stn_key and Station_restriction.stn_rstcn_key = stn_rstcn_to_frm.stn_rstcn_key
and Station.stn_key = stn_rstcn_to_frm.stn_key
Can anybody let me know as to how many joins should I have so that I don't get any cartesian product in the result set?
I am sorry if the question sounds trivial to someone but I got this basic doubt while writing a complex query for a multi-table join.
Any help in this regard is very much appreciated.
Thanks and Regards,
Ranganath
WARNING: The information in this message is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this message
by anyone else is unauthorised. If you are not the intended recipient, any
disclosure, copying, or distribution of the message, or any action or
omission taken by you in reliance on it, is prohibited and may be unlawful.
Please immediately contact the sender if you have received this message in
error. Thank you.
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: Krishnaswamy, Ranganath
INET: Ranganath.Krishnaswamy_at_blr.hpsglobal.com
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
scan all attachments. http://www.bgs.ac.uk *********************************************************************
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: Robson, Peter
INET: pgro_at_bgs.ac.uk
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author:
INET: Sunil_Nookala_at_Dell.com
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
DISCLAIMER:
This message (including attachment if any) is confidential and may be privileged. Before opening attachments please check them for viruses and defects. MindTree Consulting Private Limited (MindTree) will not be responsible for any viruses or defects or any forwarded attachments emanating either from within MindTree or outside. If you have received this message by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change and MindTree shall not be liable for any improper, untimely or incomplete transmission.
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: Naveen Nahata
INET: naveen_nahata_at_mindtree.com
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri Feb 28 2003 - 00:38:58 CST