hierarchy

SQL Query for an Organization Chart?

Hello all, I feel that this is likely a common problem, but from my google searching I can't find a solution quite as specific to my problem. I have a list of Organizations (table) in my database and I need to be able to run queries based on their hierarchy. For example, if you query the highest Organization, I would want to return th...

Multiple parents tree (or digraph) implementation sql server 2005

Hi guys, I need to implement a multi-parented tree (or digraph) onto SQL Server 2005. I've read several articles, but most of them uses single-parented trees with a unique root like the following one. -My PC -Drive C -Documents and Settings -Program Files -Adobe -Microsoft -Folder X -Drive D ...

Handling common recursive functions

I've noticed that in my project, we frequently are writing recursive functions. My question is: is there any way to create the recursive function as generic function for each hierarchy structure that is using the recursive iteration? Maybe I can use a delegate that gets the root and the end flag of the recursion? Any ideas? Thanks. ...

How to print list using hierarchical data structure?

When I run this code: foreach ($tree as $node) { echo str_repeat(' ', $node->tree_depth * 4) . $node->id . PHP_EOL; } I get well formatted text like: Food Fruit Red Cherry Strawberry Cool Not cool Yellow Banana Meat Beef Pork But I want to create a list with <ul><li>......

Hierarchical Data Models: Adjacency List vs. Nested Sets

I have a product catalog. Each category consists of different number (in deep) of subcategories. The number of levels (deep) is unknown, but I quite sure that it will not be exceed of 5,6 levels. The data changes are much more rarely then reads. The question is: what type of hierarchical data model is more suitable for such situation. T...

Method to count all items in Hierachical object list

I've got a simple class defined as: public class MyClass { //Some properties public List<MyClass> SubEntries { get; set; } //Some more properties } In another class I have a list of the above type. At the moment, I'm having a serious mental block. I just need to itereate through the list and count all occurances of MyClass....

mysql "with rollup" query morphed into a tree structure

Background: I have this "with rollup" query defined in MySQL: SELECT case TRIM(company) when 'apple' THEN 'AAPL' when 'microsoft' THEN 'MSFT' else '__xx__' END as company ,case TRIM(division) when 'hardware' THEN Trim(division) ...

Efficient datastructure for representing districts->states->nation relationship

Hi, I am looking for an efficient way to represent and retrieve the geographical relationship eg. districts->states->USA. This should accommodate any level of hierarchy eg. district->region->states->big region(East/west/south/north) -> USA. My requirements are I mostly operate at the lowest level - so getting all of them fast should...

C# algorithm for generating hierarchy

I've got a text file that looks like this: { Id = 1, ParentId = 0, Position = 0, Title = "root" } { Id = 2, ParentId = 1, Position = 0, Title = "child 1" } { Id = 3, ParentId = 1, Position = 1, Title = "child 2" } { Id = 4, ParentId = 1, Position = 2, Title = "child 3" } { Id = 5, ParentId = 4, Position = 0, Title = "grandchild 1" } I...

Displaying a custom hierarchy.

I have a simple hirachey of Tasks similar to the snipet below: public class Task { public Guid TaskId { get; set; } public Guid ParentId { get; set; } public string Name { get; set; } public List<Task> Subtasks = new List<Task>(); } What would be be the best way to display this data? A TreeView would be look ideal but ...

XML to nest folder content

Hi, I have a project to update all reports on an SSRS instance and thought I would get a list of all reports into Excel so I can tick them off as I update each one. Easy I thought. I dont use it often (at all) but XML seemed to lend itself to this. I would have something like: <Server> <ReportFolder> <ReportFolder> <Report>...

Drupal 6: Taxonomy splot up in managed fields?

So you have two taxonomies, namely: "Business Type" and "Location" This is assigned to a node called BUSINESS. In effect, when the user creates a BUSINESS node, her has to choose for example, location "New York" and type "Information Services". My problem is when: a) Capturing the taxonomy, and b) Displaying the taxonomy I want the two...

How do I limit SSAS hierarchy levels to users?

I am relatively new to ssas and am having trouble with something. The scenario: A cube with a company hierarchy (region, sub-region, country, company) Dimension security is applied by filtering the company dimension by linking username to a list of allowable companies. Enable Visual Total is switched ON so that you can only see totals...

How do I create a text file so when it is opened in Excel, rows are grouped together?

I'm collecting some data via a Perl script. The data needs to be reviewed and processed by others using Excel. Currently, I'm writing the data out as a tab-delimited text file, and Excel can open this just fine. There's a hierarchy to the data, however, and it would be easier for the reviewers to see a tree rather than a flat list. ...

SQL Server 2008 Hierarchy Data Type Performance?

How does SQL Server 2008's Hierarchy data type perform compared to using the hierarchy implementation described by Joe Celko here: http://www.intelligententerprise.com/001020/celko.jhtml? I've used Celko's method in the past with great results - but don't want to implement it for a new project unless it's better than what Microsoft has ...

Forcing interface implementations to implement hierarchy in c#

I m writing interfaces for new project and would like to get some advice. I have a class that have a subclass and it has a subclass. The tree of this classes is like this: Class Car { Wheels Wheel; } Class Wheels { Rims Rim; } So to simplify: one car has one wheel and one wheel has one rim. (cant make up other better example,...

XML element hierarchy referencing

I'm looking through possible representations for what can be considered a finite depth graph in XML format for data exchange purposes. The problematic point is how to reference nodes in edge tags. Two strategies I see are a) using unique identifiers or b) using paths. Unique IDs: <graph id="g0"> <node id="n0"/> <node id="n1"/> <...

MySQL: Calculate depth in a parent-child model?

As title says: How do I calculate a node's depth in a parent-child model? I'll need the depth to, among other things, create the indent in my list (coded with PHP). Thank you in advance. ...

Getting a call hierarchy in java

I am having real trouble tracking down a bug and it would help be a lot to know which method called a certain method. Is there an easy way to get a call hierarchy from java? Java is a small part of the app so I cannot compile and run the whole app in eclipse/net beans so I don't have access to an IDE debugger's call hierarchy. ...

Transform map with multiple values to tree?

Given a randomly distributed set of keys, with each key mapped to a set of values, how would you transform it into multiple trees? Example Data Set NB2 => {NC2 ND2} ND1 => {NG1 NH1} NA1 => {NB1} NB1 => {NC1 ND1 NE1} NA2 => {NB2} NC1 => {NF1} NE1 => {NI1 NJ1 NK1} Resulting Tree for NA1 NA1 `-- NB1 |-- NC1 | `-- NF1 |-...