I have 3 tables with their primary keys:
PLANT DEPT HOLDER
------ ------ ------
pId dId hId
Following are their relationships:
1.) A department exist in many plants.
For which I designed the table having composite key PK/FK as
DEPTinPLANT
-----------
{p_Id,d_Id}
and another relationship,
2.) A holder can be assigned to many departments of a plant.
with composite PK/FK from DEPTinPLANT and HOLDER tables
HOLDERinDEPT
------------
{{p_Id,d_Id},h_ID}
Now extracting data from HOLDERinDEPT with Select statement, I have
select *
from HOLDERinDEPT
join PLANT on p_Id = pid
join DEPT on d_Id = dId
join HOLDER on h_id = hId
Is this correct or is it required to reference first the DEPTinPLANT table then then corresponding base tables?
select *
from HOLDERinDEPT hd
join PLANT p on p_Id = pid
join DEPT d on d_Id = dId
join HOLDER h on h_id = hId
This is correct. No need to reference DEPTinPLANT
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.