hierarchy

SQL to reorder nodes in a hierarchy

I've got a 'task list' database that uses the adjacency list model (see below) so each 'task' can have unlimited sub-tasks. The table has an 'TaskOrder' column so everything renders in the correct order on a treeview. Is there an SQL statement (MS-SQL 2005) that will select all the child nodes for a specified parent and update the TaskO...

Select products where the category belongs to any category in the hierarchy

I have a products table that contains a FK for a category, the Categories table is created in a way that each category can have a parent category, example: Computers Processors Intel Pentium Core 2 Duo AMD Athlon I need to make a select query that if the selected category is Proc...

How do you sort a tree stored using the nested set model?

When I refer to nested set model I mean what is described here. I need to build a new system for storing "categories" (I can't think of better word for it) in a user defined hierarchy. Since the nested set model is optimized for reads instead of writes, I decided to use that. Unfortunately during my research and testing of nested sets...

Linq to Sql - Hierarchical Query to Find Ancestors

Given an EmployeeId, how can I construct a Linq to Sql query to find all of the ancestors of the employee? Each EmployeeId has an associated SupervisorId (see below). Entity Definition: Sample Table Data: For example, a query of the ancestors for EmployeeId 6 (Frank Black) should return Jane Doe, Bob Smith, Joe Bloggs, and Head H...

Oracle Hierarchical Query Performance

We're looking at using Oracle Hierarchical queries to model potentially very large tree structures (potentially infinitely wide, and depth of 30+). My understanding is that hierarchal queries provide a method to write recursively joining SQL but they it does not provide any real performance enhancements over if you were to manually write...

How would you design a tree view that collapses around an arbitrary middle element?

I've got an project management web application where any Project can be the child of zero or one other Project. Our director uses this function to group projects into Service Offerings, and our project managers use this to break projects down into tasks... but from the database's point of view, they're all in the Projects table. So the...

Collection type for representing a hierarchial structure in .Net 3.5

I been experimenting with the different methods for representing a hierarchical structures in memory that would allow for simple and efficient transversal both up and down to discover ancestor and descendant relationships. Does anyone have any suggestions or examples of the options that I have? Is there a collection type in .Net 3.5 th...

Build hierarchical html tags in PHP from flat data.

How do you build a hierarchical set of tags with data in PHP? For example, a nested list: <div> <ul> <li>foo </li> <li>bar <ul> <li>sub-bar </li> </ul> </li> </ul> </div> This would be build from flat data like this: nested_array = array(...

Building hierarchy objects from flat list of parent/child

I have a list of items in a hierarchy, and I'm attempting to parse this list out into an actual hierarchy of objects. I'm using modified pre-order tree traversal to store/iterate through this list, and so what I have is a subset of the tree, including all children, ordered by their "left" value. For example, given the tree: Item A It...

LINQ grouping/subquery to fill a hierarchy data strcuture

I have a DataTable that queries out something like below usergroupid...userid......username 1.............1...........John 1.............2...........Lisa 2.............3...........Nathan 3.............4...........Tim What I'm trying to do is write a LINQ statement that will return an array of UserGroup instances. The UserGroup class h...

How to build a tree view with PHP / SQL?

What's the best way to: Get the data from the db using a single query Loop through the results building e.g. a nested unordered list My table has id, name and parent_id columns. ...

What is your method of "folksonomy" tagging for files on your local machine?

Way back in the days when "delicious" was just "del.icio.us", I had assumed that everyone had finally caught on that Ontology is overrated. So why am I still having to roll my own tagging system using sqlite and a bunch of ruby scripts in order to address this obvious deficiency on my own local machine? I can tag on-line web links, blo...

Using master pages with multiple entities

I'm beginning to plan a complete redesign of our departments intranet pages. As it stands, every department gets their own folder within root. They all share the same look and feel but don't use CSS everything in each file is straight up static text. Basically, if a change has to be made to the header, every file must get changed. The nu...

CSS hierarchy classes and IDs

I am building a menu using XHTML,CSS, and jQuery and I ran into a problem with my CSS. Here is my test page, and here is my css. What I am having problems with is that my .subMenu class is inheriting the properties of my #menu, the background colors and sizes are the same. I am looking for a solution that leaves .subMenu as a class s...

How can I select all leaf nodes in a SQL hierarchy under a given node?

I have a set of data that models a hierarchy of categories. A root category contains a set of top-level categories. Each top-level category contains a set of sub-categories. Each sub category has a set of organizations. A given organization can appear in multiple sub categories. The leaf nodes of this hierarchy are organizations. An o...

Is there a good, re-usable parser that converts a string into a hierarchy of lists?

I'd like to take a string such as this: [One, Two[A, B[i, ii, iii, iv], C], Three] And convert it into a hierarchy of lists, so that if I execute code such as the following: Console.Write(myList[1][1][2]); The output will be: iii I'm hoping that this is a common enough requirement that there's some simple parsing code written in...

How can I query hierarchies with LinqToSQL?

I have a hierarchy that I'd like to query with LinqToSql: Country -> Region -> City -> ZipCode Each entity holds both a reference to it's parent (eg. Region.Country) and a collection of it's children (eg. Region.Cities). I'd like to eager load each entity's parent along with Countries and Regions but lazy load cities and zip codes. T...

PHP/MySQL - building a nav menu hierarchy

So the final menu will look something like this: Item B Item B-1 Item B-1-2 Item B-1-1 Item A SubItem A-1 SubItem A-2 Item C Based on the following DB records: id menu_title parent_menu_id menu_level weight 1 Item A 0 1 ...

Exchange Server Organizational Structure

I need to figure out a way to build a hierarchy by Director->Manager->Employee from an exchange server. I have very limited knowledge of exchange, so does anyone have any ideas for me? Thanks ...

Ordering hierarchy from recursive query results in SQL 2005

I've got a 'Task' table with the following columns (the TaskOrder is for ordering the children within the scope of the parent, not the entire table): TaskId ParentTaskId TaskName TaskOrder I've got this CTE query to return all the rows: with tasks (TaskId, ParentTaskId, [Name]) as ( select parentTasks.TaskId, parentTa...