Reputation: 3564
New to designing databases. I currently try to create a database in MS Access.
The two tables I need are:
PEOPLE
with columns ID, NAME.COMPANY
with columns ID, EMPLOYEE, SUPERVISORCan I link the EMPLOYEE
with the PEOPLE.ID
and SUPERVISOR
again with PEOPLE.ID
?
Does it make sense? I am asking because Access created a duplicate PEOPLE_1
table to link the second column.
Thanks,
Upvotes: 0
Views: 46
Reputation: 445
Yes. The way Access made it, works. You need the PEOPLE table twice, so you can reference two different records (the employee and the supervisor) at the same time.
If you want, you can also set an alias for both PEOPLE tables. Example:
SELECT COMPANY.ID, emp.NAME, sup.NAME
FROM COMPANY LEFT JOIN PEOPLE AS emp ON COMPANY.EMPLOYEE = emp.ID
LEFT JOIN PEOPLE AS sup ON COMPANY.SUPERVISOR = sup.ID
(I didn't use Access for quite a long time. Maybe you have to put brackets around one of the join statements to make it work)
Upvotes: 1