Re: Modeling an Employee/Company Hierarchy
I have recently worked through a similar problem. I'm building a site to manage characters, and the organizational structure of a military unit in a game I run in my spare time. In my case i wanted to have one table to store all of the organizational levels (I called them divisions), with a type field that helped determine what level they were at. I then had a position table which stored the various position names, and also linked them to a particular division and a character. Thus each character could have multiple positions, in different divisions. What I'm not sure about is whether this would work for your situation. You said you think the structure is like this Example: CEO ---> Directors > Managers ---> Individual contributors. If you don't have unit divisions within your unit, you could substitute each position into the tree with a parent ID pointing up, and then have a link table that would allow the individual to have or report to many. In my case, I was torn between putting the semantics of the Positions into the Tree's at a level below their respective divisions, and then only attaching characters there, but I really felt that was not a good idea for my current project. If an employee can serve multiple positions and report to multiple people, it almost sounds like you might need one table for the position -> Character relationship, and another to store the character to multiple character/managers. I guess it depends on how much complexity you need. Hope this gives you some ideas. Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Modeling an Employee/Company Hierarchy
There are several options: 1) One table Employees with relationship to itself, thus able to contain a hierarchy of employees. 2) Three tables, OrganizationUnits, Positions, Employess, with relationships as: - Employees --- are employed in one or more ---> Positions - OrganizationUnits --- offers one or more ---> Positions - Positions --- manages one or more ---> Positions Thus: - an employee may participate in one or more positions offered by organization units. - an employee may fulfill a position being managed by another position. Hope this helps you on the way, John On Apr 8, 8:13 am, Shien wrote: > Hi All, > > Apologies if this has been answered multiple times before but I can't > seem to find a post which answers this question in full rather than > just a subset of it. > > Problem: An employee has zero or more managers and at the same time, > might be managing zero or more employees. > > Example: CEO ---> Directors > Managers ---> Individual > contributors. > > What is the proper way to model this? > > It sounds like it is a HABTM relationship but I'm confused how to > model this for a generic case. In the example above, I was initially > thinking that I might need 3 relationship tables to model this > (CEO_Directors, Directors_Managers, etc.) each containing employee > IDs. But what if suddenly they created a position of Vice Presidents > who reports to the CEO? Or worse yet, what if their positions just > changed names? > > When I hadn't even considered using CakePHP and was just thinking > about the database, I had initially planned to just add a column > "Reports To" in the employee table which would contain the employee ID > of that employee's manager. I could then recursively build out the > relationships between all employees (I think). > > Any direction or help would be greatly appreciated! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Modeling an Employee/Company Hierarchy
Hi All, Apologies if this has been answered multiple times before but I can't seem to find a post which answers this question in full rather than just a subset of it. Problem: An employee has zero or more managers and at the same time, might be managing zero or more employees. Example: CEO ---> Directors > Managers ---> Individual contributors. What is the proper way to model this? It sounds like it is a HABTM relationship but I'm confused how to model this for a generic case. In the example above, I was initially thinking that I might need 3 relationship tables to model this (CEO_Directors, Directors_Managers, etc.) each containing employee IDs. But what if suddenly they created a position of Vice Presidents who reports to the CEO? Or worse yet, what if their positions just changed names? When I hadn't even considered using CakePHP and was just thinking about the database, I had initially planned to just add a column "Reports To" in the employee table which would contain the employee ID of that employee's manager. I could then recursively build out the relationships between all employees (I think). Any direction or help would be greatly appreciated! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---