Questions tagged [hierarchical-data]

Hierarchical data reflects a set of parent-child relationships. These can be found in a genealogy, a taxonomy, a list of requirements for parts assembly, and innumerably other instances. Methods for dealing with hierarchical data are often essential for data management and analysis.

Hierarchical data reflects a set of parent-child relationships. As Materials Resource Planning was developed by manufacturers in the 1950s, hierarchical data management emerged as a theoretical and practical discipline. A manufacturer uses the term Bill of Materials (BOM) for the set of items required to assemble a parent item; the term BOM was adopted by mathematicians and software developers, and it is used today in both realms.

Hierarchical data is ubiquitous and has called forth some of the most important and complex work of database management. It has also propelled object-oriented programming.

The key design element is recursion. Imagine starting at the trunk of a tree and visiting every leaf; this theoretical exercise would require an enormously large number of decision points occurring in a nested or recursive pattern. Requirements for this analysis are remarkably varied and have produced entire sub-disciplines of database design.

2030 questions
40
votes
1 answer

WPF Treeview Databinding Hierarchal Data with mixed types

I have a bit of a complex situation with WPF Treeview Binding. I have spent the last 2 days trying Google it, and this is the closed I came up with, but it doesn't solve the issue. Here is the situation: I have an object that looks like…
thorkia
  • 1,972
  • 1
  • 20
  • 26
36
votes
3 answers

Hierarchical/tree database for directories path in filesystem

I want to store the directories (present on the disk) into a database, maintaining their hierarchical/tree structure. Here's a figure: (ROOT) / \ Dir2 Dir3 …
JOHN
  • 587
  • 1
  • 5
  • 9
35
votes
5 answers

SQL recursive query on self referencing table (Oracle)

Lets assume I have this sample data: | Name | ID | PARENT_ID | ----------------------------- | a1 | 1 | null | | b2 | 2 | null | | c3 | 3 | null | | a1.d4 | 4 | 1 | | a1.e5 | 5 | 1 | |…
Maxim Veksler
  • 29,272
  • 38
  • 131
  • 151
34
votes
2 answers

How to represent a tree like structure in a db

I'm starting a project and I'm in the designing phase: I.e., I haven't decided yet on which db framework I'm going to use. I'm going to have code that creates a "forest" like structure. That is, many trees, where each tree is a standard: nodes and…
Guy
  • 14,178
  • 27
  • 67
  • 88
32
votes
9 answers

Getting all parent rows in one SQL query

I have a simple MySQL table thats contains a list of categories, level is determined by parent_id: id name parent_id --------------------------- 1 Home 0 2 About 1 3 Contact 1 4 Legal 2 5 Privacy 4 6 …
Alex
  • 6,497
  • 11
  • 47
  • 58
31
votes
4 answers

Generating Depth based tree from Hierarchical Data in MySQL (no CTEs)

Hi For many days I have been working on this problem in MySQL, however I can not figure it out. Do any of you have suggestions? Basically, I have a category table with domains like: id, name (name of category), and parent (id of parent of the…
bluedream
  • 999
  • 2
  • 12
  • 15
30
votes
10 answers

Is there a way to convert CSV columns into hierarchical relationships?

I have a csv of 7 million biodiversity records where taxonomy levels are as columns. For instance: RecordID,kingdom,phylum,class,order,family,genus,species 1,Animalia,Chordata,Mammalia,Primates,Hominidae,Homo,Homo…
29
votes
6 answers

Fatal error: Nesting level too deep - recursive dependency?

I have a complex hierarchy of nested objects, with all of the child objects (stored an array of objects in the parent class) containing a property linking back to their parent: fairly simple and straightforward, with no real problems. If I do a…
Mark Baker
  • 209,507
  • 32
  • 346
  • 385
27
votes
4 answers

How to store a tree in SQL database

I have to store a tree in a database, so what is the best way to do this? Show the method you use and name its pros and cons. (I am using SQL Server 2005)
kalan
  • 1,752
  • 4
  • 20
  • 35
26
votes
9 answers

Expressing recursion in LINQ

I am writing a LINQ provider to a hierarchal data source. I find it easiest to design my API by writing examples showing how I want to use it, and then coding to support those use cases. One thing I am having trouble with is an easy/reusable/elegant…
Rex M
  • 142,167
  • 33
  • 283
  • 313
25
votes
13 answers

Move node in nested set

I'd need a MySQL query that moves a node and all its children within a nested set. I found this site, but that function just seems so illogical - there's no universeid or treeid in a nested set model, and the code itself is just longer than what…
Ivar
  • 4,344
  • 6
  • 38
  • 53
24
votes
3 answers

Storing hierarchical data in Google App Engine Datastore?

Can someone illustrate how I can store and easily query hierarchical data in google app engine datastore?
23
votes
7 answers

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 =…
Judah Gabriel Himango
  • 58,906
  • 38
  • 158
  • 212
23
votes
2 answers

Counting number of children in hierarchical SQL data

for a simple data structure such as so: ID parentID Text Price 1 Root 2 1 Flowers 3 1 Electro 4 2 Rose 10 5 2 Violet 5 6 4 Red Rose …
Dennis G
  • 21,405
  • 19
  • 96
  • 133
23
votes
2 answers

Smooth transitioning between tree, cluster, radial tree, and radial cluster layouts

For a project, I need to interactively change hierarchical data layout of a visualization - without any change of the underlying data whatsoever. The layouts capable of switching between themselves should be tree, cluster, radial tree, and radial…
VividD
  • 10,456
  • 6
  • 64
  • 111