Solved

Detecting a cartesian product

Posted on 2004-04-16
6
819 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now