Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

reporting on Org chart data

Ok -

Ive been stumped by this one for a few days..

So I finally got access to my company's cost center database..

Basic structure -

id | costCenterName | costCentercode | parentID
1, organization, n1, <null>
2,finance, n2, n1
3, billing, n3, n1
4, accounts, n4, n3

etc..

then ive got another table that has all employees and which cost center they are in ..

So Ive been tasked with coming up with a reporting structure where someone can supply me with their costCenter code and I have to tell them how many employees they have..

Only not just their costCenter.. but their's as well as all costCenters that report up to their's...

Ive got a recursive program I can write to get this information, but with 3k costCenters and over 35k employees.. takes way to long for a report on the web..

ANy ideas on how to manipulate this data or write some kind of sql query that could return results in timely manner?

Thanks!

Will
[1080 byte] By [nimmow] at [2007-11-11 8:45:41]
# 1 Re: reporting on Org chart data
What kind of database?
Phil Weber at 2007-11-11 23:47:00 >
# 2 Re: reporting on Org chart data
Sql 2000
nimmow at 2007-11-11 23:48:05 >
# 3 Re: reporting on Org chart data
See if these help:
http://www.sqlteam.com/item.asp?ItemID=8866
http://vyaskn.tripod.com/hierarchies_in_sql_server_databases.htm
Phil Weber at 2007-11-11 23:49:04 >
# 4 Re: reporting on Org chart data
:SICK: The first link looks like it may get me in the direction I need.

Im starting to realize the size of the data involved may limit the effectiveness of reporting on the tree.

What weve been asked to do involves not only to display the tree, but also to assign different statistics (such as employee count) for each level..

For example we might have

Office of Board of Directors (35,000)
--Home Office (25,000)
--Sales (15,000)
--Finance (5,000)
--auto(2,500)
--home(2,500)
--Field Office (10,000)
--marketing (5,000)
--advertising (5,000)

So while this can be accomplished using recursion, it may not be possible to perform such a query a time amount acceptable to pull up for a web report (supposing you wanted to allow the customer to plug in a cost center for their level and see reports from that level down)

But i do thank you for the first steps help..

Ill post back when I reach my next roadblock..
nimmow at 2007-11-11 23:49:58 >