I want to store this information in a database:
Company
|
|-- Dept 1--,
| \->Employee 1
| |->Employee 2
|
|-- Dept 2--,
| \->Employee 3
|
|-> Employee 4
\-> Employee 5
I’ve already got this far: I need a employee table and the department and company items are just the same so they should be in the same table…
employee // id | information...
branch // id | information....
Each employee should be linked to a branch. And each branch can be connected to another branch…
employeeBranch // employee.id | branch.id | enum(current, historical)
branchBranch // branch.id | branch.id
This makes it possible to have multiple levels of branches…
But I’m doubting if this is The way to do it..
If employees can only belong to one branch and branches can only be a child to one branch then you might consider adding a column to represent this information instead of whole new tables:
If you have many to many relationships for employee/branch and branch/branch then I think your original structure is fine.