Complicated relationship between two tables

H

hikaru

hi,

I have a problem in viewing related data between two tables. my two tables
are:

Tbl_Company:
CompanyID
Company Name
CompanyType (Consultant or Contractor)

Tbl_Projects:
ProjectID
ProjectName
ConsultantID (CompanyID FK)
ContractorID (CompanyID FK)

so, I have two relationship between the two tables. both are One-to-Many and
from Tbl_Company to Tbl_Projects.

How can I solve the issue? Are such relationships possible?
 
J

John W. Vinson

hi,

I have a problem in viewing related data between two tables. my two tables
are:

Tbl_Company:
CompanyID
Company Name
CompanyType (Consultant or Contractor)

Tbl_Projects:
ProjectID
ProjectName
ConsultantID (CompanyID FK)
ContractorID (CompanyID FK)

so, I have two relationship between the two tables. both are One-to-Many and
from Tbl_Company to Tbl_Projects.

How can I solve the issue? Are such relationships possible?

Yes, this is a perfectly reasonable structure: you simply have two independent
foreign keys to the same table. You can display the data by adding
tbl_Projects to the query window, and adding tbl_Company *twice* - once
joining to ConsultantID and once to ContractorID. If a given project might
have only a consultant and no contractor, or vice versa, you may need to use a
Left Outer Join on both relationships.

You'ld do the same thing to establish RI - add tbl_Company twice. Access will
alias the second instance as tbl_Company1.
 
H

hikaru

Thanks, it worked ^_^

John W. Vinson said:
Yes, this is a perfectly reasonable structure: you simply have two independent
foreign keys to the same table. You can display the data by adding
tbl_Projects to the query window, and adding tbl_Company *twice* - once
joining to ConsultantID and once to ContractorID. If a given project might
have only a consultant and no contractor, or vice versa, you may need to use a
Left Outer Join on both relationships.

You'ld do the same thing to establish RI - add tbl_Company twice. Access will
alias the second instance as tbl_Company1.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top