If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Designing DB to represent an organisations hierarchy

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-16-11, 19:12
JHamill JHamill is offline
Registered User
 
Join Date: Jun 2009
Posts: 5
Designing DB to represent an organisations hierarchy

Hi guys,

I am currently working on a web-development project where I am required to develop a database that fits the following requirements at this stage:

1) The database represents the companies employee hierarchy. For instance, it will be possible to view which employees report to which manager.

2) Users of the system (company employees) can be any one of three roles;
Employee
Manager
System Administrator

I intend to have a user table, where all system users are stored. A seperate table named 'role' with 'roleID' as the PK and a second attribute of 'roleDescription'.
Each instance of 'user' will have a roleID.

To meet the requirements of representing the company hierarchy I intend to include an attribute in the 'user' table of 'managerID' which refers to the 'userID' from the same table - with those users that are managers having NULL for the 'managerID'. Much the same they have described in this example: Database Design - Recursive associations

Would this be the right way to approach this?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 02-17-11, 05:02
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by JHamill View Post
Would this be the right way to approach this?
yes

it's called the adjacency list model, and it is characterized by the use of a "parentid" column (in your case, managerid)

by the way, that tomjewett article is really good

a similar hierarchical structure is Categories and Subcategories
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-17-11, 06:40
JHamill JHamill is offline
Registered User
 
Join Date: Jun 2009
Posts: 5
Thanks for the quick response r937.

The link you provided is extremely useful - so useful in fact I shall be referencing it.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On