Solved

Detecting a cartesian product

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Read about achieving the basic levels of HRIS security in the workplace.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

691 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