Solved

Detecting a cartesian product

Posted on 2004-04-16
6
870 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
[X]
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
  • 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can i Import Access Table Into Oracle Using Toad 36 274
Powershell script 13 120
Multiple MSSQL instances on same server 4 55
A beginner asks: Which macos postgreSQL client? 5 85
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
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…

756 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