hierarchical-data

Hierarchical query in SQL Server 2005

I have a data structure inside a table in SQL Server 2005 representing a chain of related objects. Each object can have replacements in many steps. I want to perform a query that returns all objects and each object's leaf in the replacement chain. The data: id replacement 1 null 2 3 3 null 4 5 5 6 6 null The result shoul...

What is the best way to manage array or arrays in classical ASP

PHP provides associative arrays but there is no such thing in classical asp. I am looking for a class or function that allows me to create and traverse a hierarchy similar to this: United States Washington Electric City Banks Lake Lake Chelan Wapato Point Gig Harbour Mexico Nayarit Aticama Asia India ...

Trying to use linq to search based on table with hierarchical data.

Duplicate many times over (and also these) I have a table called Types that has the following columns. ID Level Name ParentID (The ID of the parent row) and a table called ParentObject which has the following columns. ID TypeID there are 4 different level (possibly to be expanded to more). So if I had ID: 1 Level: 0 Name: Level0 Pa...

How do I get the count of all the products in a category and its sub categories (and sub-sub categories)?

The category table looks like somewhat as below: id -- name -- parent_id 1 -- Men -- 0 2 -- Women -- 0 3 -- Shirts -- 1 4 -- Half-sleeve -- 3 5 -- Full-sleeve -- 3 Relationship table: Product_id -- Category Id 1 -- 2 2 -- 2 3 -- 4 .... I can retrieve the number of products in any one category and...

Determine the hierarchy of records in a SQL database

I've got a problem I was wondering if there's an elegant solution to. It is a real business problem and not a class assignment! I have a table with thousands of records, some of which are groups related to each other. The database is SQL 2005. ID is the primary key. If the record replaced an earlier record, the ID of that record is i...

How can I create a multi-hierarchical 'tree'? (If it can be called a tree)

Hi, i have a list of say courses and certificates and fun_days. These are all called objects. Every object has its requirements object_requirements. A requirement can be either one of the objects or several of them. You can take any object without object_requirements as a starting point. "Everybody is allowed to have those objects." S...

Hierarhical data and BerkeleyDB

Good news! Since version 4.8 BerkeleyDB has c# interface. BerkeleyDB is a quite interesting thing for me due to it's non-SQL nature. I know it's an excellent tool if someone wants to store a lot of key/value pairs. And I know about 'attachable' tables. What i don't know is how to store hierarchical data with BerkeleyDB. Is it suitable f...

TSQL CTE and a Graph of Sorts

With a table of the following structure and sample data: TableActivity ------------- Type VARCHAR(8) Activity VARCHAR(8) RelatedActivity VARCHAR(8) Type Activity RelatedActivity ------------------------------------------ Start a - Transfer a b Start b ...

Designing MVC URL scheme for hierarchical system

So imagine I'm building a Multi User Dungeon system using a MVC web application. To describe the areas the player can explore, the system can contain a number of Maps, which will consist of Rooms and Doors - where doors connect two Rooms. Consider the authoring part of the system. To create a Map is easy - I need URLs like: /Author/Map...

Non framework implementation of a hierarchical drop down for Firefox.

I need a hierarchical drop down <select><option/></select> for use within a browser, preferably Firefox. I'd rather not use a framework like jQuery. Please spare me the questions as to why. ...

Database patterns for partitioning large hierarchical datasets

Are there any best-pratices/patterns or general advice for partitioning large amounts of hierarchical data? Think of, say, a database of all the people in a given country and tracking who has worked with who. Thinking of the "person" entities in isolation, if a lot of data were to be kept about each person then a natural approach seems...

Tree data in MySql database table

I have a table that uses Adjacency list model for hierarchy storage. My most relevant columns in this table are therefore: ItemId // is auto_increment ParentId Level ParentTrail // in the form of "parentId/../parentId/itemId" then I created a before insert tigger, that populates columns Level and ParentTrail. Since the last column al...

Convince entity context (EF1) to populate entity references

I have an entity with self reference (generated by Entity Designer): public MyEntity: EntityObject { // only relevant stuff here public int Id { get...; set...; } public MyEntity Parent { get...; set...; } public EntityCollection<MyEntity> Children { get...; set...; } ... } I've written a stored procedure that retu...

How to avoid circular relationship in SQL-Server?

I am creating a self-related table: Table Item columns: ItemId int - PK; Amount money - not null; Price money - a computed column using a UDF that retrieves value according to the items ancestors' Amount. ParentItemId int - nullable, reference to another ItemId in this table. I need to avoid a loop, meaning, a sibling cannot become a...

Question about Hierarchical data

I am reading the following article, http://articles.sitepoint.com/article/hierarchical-data-database/2 about"Storing Hierarchical Data in a Database". This is talking about these structures. http://sitepointstatic.com/graphics/sitepoint_numbering.gif and http://sitepointstatic.com/graphics/table02.gif I don't understand the following p...

Hierarchical structure iteration and LINQ

Hello! Assume that we have class public class RMenuItem { public List<RMenuItem> ChildrenItems { get; } public decimal OperationID { get; } public string Name { get; } } as you can see - each menuitem could have children items - as usual in menu. My task is to iterate through each items of this list and apply some action...

Adjacency List Model with two tables

So I think my issue boils down to two questions: How do I build a traversable tree structure in PHP when the tree is stored in MySQL (between two tables) using the Adjacency List Model approach while keeping performance in mind? What's a maintainable approach to displaying the tree in the needed formats without duplicating traversal co...

Python Hierarchical QcomboBox: clean-up list

Hi Everybody, I have a hierarchical two combo-box. The first combo-box displays a list of customerNames, i.e. different companies from a MySQL db. Each customer has branches in different cities. Then, when a customer name is chosen from combo-box1 option list, e.g. {Aldi, Meyer, Carrefour, WalMart}, for that particular customer, a list...

Flex hierarchical data - advanced data grid - unable to delete and change to leaf

Folks, When all the children are gone the folder icon does not change. If I walk the collection and then force the children = null, then the folder changes to a sheet (leaf) icon, as you would expect by looking at the HierachicalCollection class. However when I go to add a new leaf to the summary folder the folder reappears and the down...

Have multiple trees in one table using CakePHP Tree Behavior

I'm converting a flat list into a tree in my CakePHP app and found that there is an existing behavior that has this functionality. My table is not one giant tree, but consists of many user-generated trees: basically, each user can create their own folder structure. However it seems that the Tree Behavior would only keep track of lft/rght...