-2

I need to join three tables in Oracle; I have code but I am not sure if it is totally right.

FROM DISTRICT D1 
JOIN EMPLOYEE E1 ON D1.DISTRICT_ID = E1.DISTRICT_ID
JOIN TOTAL_PAB T1 ON E1.EMP_ID = T1.EMP_ID

I need to join the table DISTRICT, EMPLOYEE, AND TOTAL_PAB. Where do the primary and foreign keys go in this join table statement?

  • Primary key for EMPLOYEE is EMP_ID and FK is DISTRICT_ID.
  • Primary key for DISTRICT is DISTRICT_ID and FK is SUPERINTENDENT_ID.
  • Primary key for TOTAL_PAB is PAB_ID and FK is EMP_ID.
APC
  • 144,005
  • 19
  • 170
  • 281

1 Answers1

0

The query seems legit, but you should give us some more informations for a better answer.

Generally, it's not important if a field is key or not: the important thing is that ONLY fields in "ON" part of the join statement will be used for matching rows.

Marco
  • 127
  • 6