I need help figuring out the best table architecture for a certain situation. Suppose I have Employees at a company. An employee can belong to more than one departement in the company. For example, Mary below can belong to both the Engineering and Sales
departements? I was thinking I could use two tables for this. However, I am thinking that maybe a third join table is needed. I just don't know how to go about setting this up. Any ideas? Should I use a third table to join the two tables below? If so, how
so?
AppDevForMe
Participant
1392 Points
1326 Posts
Question about table architecture. Is a join table needed?
Apr 04, 2012 01:38 AM|LINK
I need help figuring out the best table architecture for a certain situation. Suppose I have Employees at a company. An employee can belong to more than one departement in the company. For example, Mary below can belong to both the Engineering and Sales departements? I was thinking I could use two tables for this. However, I am thinking that maybe a third join table is needed. I just don't know how to go about setting this up. Any ideas? Should I use a third table to join the two tables below? If so, how so?
Employee
Jack
Terry
Mary
Diane
Jeremy
Ricky
Departement
Engineering Procurement Sales Shipping
Rab Nawaz Kh...
Participant
939 Points
201 Posts
Re: Question about table architecture. Is a join table needed?
Apr 04, 2012 03:20 AM|LINK
in my opinion it will be so good to use third table which contains
TableId primary key
EmployeeID
DepartmentID
and then join this table with Employees and Departments table,
it shows the one to many for employees and Departments table and many to one relation of thirdTable with Employees and Departments
it will be easy to manipulate, duplication will not occur in Departments and Employees tables, will be easy for the reportring
and you will easily insert the employees which are in defferent departments and also it will be flexible for the more issues as mentioned
hope you will get my point
Thanks