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

Home -> Community -> Usenet -> comp.databases.theory -> Table Join Question

Table Join Question

From: <sriniv79_at_my-deja.com>
Date: Mon, 21 Aug 2000 13:32:11 GMT
Message-ID: <8nrb0s$a97$1@nnrp1.deja.com>

Suppose I have three Tables - EMP (EmpID is PK), PROJECT (ProjID is PK, EmpID is FK) and ROLE (ProjID is FK, EmpID is FK and RoleDesc is char data).

To get the role description of an Employee in a Project, I would Join EMP, PROJECT and ROLE.

While Joining the tables, should I join using the Foreign keys like this:

((EMP join Project on Project.EmpID = EMP.EmpID) join ROLE on ROLE.empID
= Project.EMPID and Role.ProjectID=Project.ProjID)

Or using the primary keys from the original tables like this:

((EMP join Project on Project.EmpID = EMP.EmpID) join ROLE on ROLE.empID
= EMP.EMPID and ....)

In the second example, Role.EmpID is compared to Emp.EmpID instead of Project.EmpID.

Which is correct way of doing the join and why? Are there any optimization related issues?

TIA,
Srini

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Mon Aug 21 2000 - 08:32:11 CDT

Original text of this message

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