hierarchical-data

Does Mysql 5 have procedures for managing hierarchical data?

I use nested set model for saving hierarchical data into database table and I'm interested in if MySQL has built-in support for adding/deleting nodes or I have to write stored procedures from scratch. Thanks. ...

How do you create a multi-dimensional array from hierachically stored SQL data using the adjacency list method?

Hierachical Data from SQL Adjacency List Model In my model I have a series of objects, each stored with their parent id. I am using the Adjacency list model as my hierachy method. All examples of Adjacency list simply output there and then. None try to create a multi dimensional array from the result set. --------------- | id | paren...

How to retrieve the path to a node in a tree - efficiently (related to the post 'parse a flat table into a tree?')

This question is a follow up to this post: http://stackoverflow.com/questions/192220/what-is-the-most-efficientelegant-way-to-parse-a-flat-table-into-a-tree I liked the ClosureMap solution, but I have an additional problem to solve. How can you easily retrieve the path to a particular node in a tree? For example, if you look at the t...

Handling Hierarchy Data

Hi guys, I have Name Company Nr Mother Company Nr Company A 100 Company B 101 100 Company C 102 100 Company D 103 102 Company E 104 100 in a BusinessObject that I extracted from an XML document I need t...

Bind Infragistics UltraWebGrid with Hierachical view to collection of objects

I have a list of entities that i want to bind to my UltraWebGrid. The Class definition of the entity has the following structure public class Parent { public Guid Id { get; set; } public String Name { get; set; } public IList<Child> Children { get; private set; } } public class Child { public Guid Id { get; set; } public Guid ...

Subsonic 3 Hierarchic Collection Creation?

I have a single table with a hierarchy inside. I am using ActiveRecord. How can I convert this into a hierarchic collection that I can then bind to a WinForms or WPF treeview? Thanks. ID Name ParentID 1 ALL 1 2 ARGENTINA 1 15 AUSTRALIA 1 16 NW 15 17 BLACKTOWN 16 18 CORLETTE 16 19 PRIMBEE 16 20 TWEED HEADS 16 21 QL 15 22 AS...

Hierarchical Structure Vs Flat Structure

What are the pros and cons of using hierarchical data structure over flat data structure (more like tagging systems in blogs) Ecommerce systems like ebay, yahoo shopping and yellow pages use product and service hierarchy trees to represent data but if one wants to create a open tagging based ecommerce system then what are the possible c...

What is the fastest/easiest way to denormalize this heirarchical table into a flat table?

I have the following hierarchical table: Table Category: CategoryId, ParentCategoryId, CategoryName 1, null, SomeRoot 2, 1, SomeChild 3, 2, SomeGrandchild 4, 3, SomeGreatGrandchild (note this sample data doesn't include a leaf on an earlier node than level 4, but that is possible). The data will never go deeper than level 4, if that i...

Storing XML document in pre-parsed binary format

My application need to store large amounts of XML-like hierarchical information with the following requirements: Fast to read Minimal memory consumption Typed data instead of merely text Any suggestions for a binary format that fulfills these goals? ...

SQL Server: Select Parent-Child

Hi I have SQL Server 2008 with a table called ProductCategories designed like this: Id | Name | ParentId 71 PCs NULL 32 MACs NULL 3 Keyboard 1 9 Mouse 1 5 Screen 1 11 Keyboard 2 7 Mouse 2 8 Screen 2 I would like to select from this table, and get a result set like t...

Entity framework: eager load whole self-referencing table

Hi, i have standart self-referencing table of categories. In entity model i have made association "Children" and "Parent". It is possible to load whole Category object without lazy loading? if i use the code bellow, it's load only to second level (depth). db.Categories.MergeOption = System.Data.Objects.MergeOption.NoTracking; var q...

What kind of DB structure should I use for a site has infinite sub-category?

For example, "Dole Banana" is a kind of product, it's listed under the "Bananas" category, when I open the "Fruits" category, I want to see "Dole Banana". + Food |--+ Fruits |------+ Bananas |------+ Apples |--+ Vegetables |------+ Onion |------+ Spinach ...

Modelling data loading techniques for a MVC web application

Hi all, When you are developing an MVC based website that will, for instance, be able to display profile information about a user, how do you usually model data if it's coming from a relational database so that it would still be useful if the persistent storage mechanism changes (perhaps to some SOAP or XML based webservice)? For examp...

Hierarchy Problem -> Replace Recursion with Linq Join??

I have a self referential table, which has ID, ParentID (nullable). So, the table contains many nodes, each node could be the root in the hierarchy (parent is null), or any level of the hierarchy (parent exists elsewhere in the table). Given an arbitrary starting node, is there an elegant linq query that will return all children of the...

WPF Nested ListBox Databinding using ViewModel

Hi All, This is a long one . I am adding code so that you can see what I am trying to do. Let me know if anything is not clear I am trying to get selected items from nested listbox in multiselct mode . Here is code ( removed lot of unwanted stuff) public class Item { public string Name { get; set; } public IList<Item> SubItem...

Hierarchical Query

Hi all, I hope I'm able to explain the problem that is puzzeling me. I have the following hierarchical data set (this is just subset of 34K records) PARENT_ID CHILD_ID EXAM TUDA12802 TUDA12982 N TUDA12982 TUDA12984 J TUDA12984 TUDA999 J TUDA12982 TUDA12983 N TUDA12983 TUDA1532...

How to retrieve the children categories without the children of those ones ?

Here is my statement : SELECT ( COUNT( parent.categoryName ) - ( sub_tree.depth +1 ) ) AS depth, CONCAT( REPEAT( '', ( COUNT( parent.categoryName ) - ( sub_tree.depth +1 ) ) ) , node.categoryName ) AS categoryName FROM Categories AS node, Categories AS parent, Categories AS sub_parent, ( SELECT node.categoryName, ( ...

DB design/latency/concurrency, awful headache

I have a client-server application which gets all the data out of a couple of tables, recalculates something and stores it. Example: Each Item has a 'Bill of Materials' = the list and quantities of which other items it is made out of. Therefore the cost of an item is the sum of the cost of the items in its BOM * their quantities. Ultim...

Regular Expression Problem: Match in Context

I have a structured file with hierarchical text which describes a GUI in Delphi (a DFM-File). Let's assume I have this file and I have to match all "Color = xxx" Lines, which are in the context of TmyButton (marked), but not those in other context. Within the TMyButton-Context there won't be a deeper hierarchical level. object frmMain:...

Generate breadcrumbs of categories stored in MySQL

In MySQL, I store categories this way: categories: - category_id - category_name - parent_category_id What would be the most efficient way to generate the trail / breadcrumb for a given category_id? For example breadcrumbs(category_id): General > Sub 1 > Sub 2 There could be in theories unlimited levels. I'm using php. UPDATE: I saw...