Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Detecting a cartesian product

Posted on 2004-04-16
6
858 Views
Last Modified: 2012-08-14
I am developing a query builder form something similar to TOAD.
When the user selects multiple columns from various tables i need to detect whether the tables can be joined or not. I want this to be done so that i can avoid a cartesian product when the final query is built and run on the server.
Is there a way to detect if two tables would cause a cartesian product / not.
0
Comment
Question by:vikramrathour
  • 2
6 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 10848409
which database system?

how are you expecting the joins to be specified anyway?

0
 

Author Comment

by:vikramrathour
ID: 10848532
I am using Oracle Database.
The joins will either be specified by the user or i would be picking up the primary keys of both tables and try and equate them.
Thats what i am thinking of right now but can some one tell me a better solution.
0
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 25 total points
ID: 10848545
in the main your joins will be on a foreign key to primary key basis  
if your dealing with normalised tables....

the simple way to stop catesian product would be to "demand" the join criteria whenever the user starts to
use a column from a new table...

to automatically do it / present some options to the user then you need to query the "system catalog/tables"
to attempt to detect the foreign key relationsships / indexes available and
present them as options....

sorry i'm not an Oracle "Expert"
0
 
LVL 6

Assisted Solution

by:musdu
musdu earned 25 total points
ID: 10848626
Hi,

you can find primary key-foreign key relations between tables and columns using dba_constraints table.

regards
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question