Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Number of joins in the query

RE: Number of joins in the query

From: DENNIS WILLIAMS <DWILLIAMS_at_LIFETOUCH.COM>
Date: Thu, 27 Feb 2003 08:04:25 -0800
Message-ID: <F001.0055B993.20030227080425@fatcity.com>


Ranganath

   On looking closer at your model, it appears you may have duplicated keys. That may be the source of your confusion. Your model may not be properly normalized. What is the relationship between the three tables? It appears that Station is the parent of the two other tables, but its key is propagated to both of the other two. What is the relation between Station_restriction and Stn_rstcn_to_frm? What is the primary key for Stn_rstcn_to_frm?

Dennis Williams
DBA, 40%OCP, 100% DBA
Lifetouch, Inc.
dwilliams_at_lifetouch.com

-----Original Message-----
[mailto:Ranganath.Krishnaswamy_at_blr.hpsglobal.com] Sent: Thursday, February 27, 2003 8:59 AM 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 two
joins 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).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: DENNIS WILLIAMS
  INET: DWILLIAMS_at_LIFETOUCH.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 Thu Feb 27 2003 - 10:04:25 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US