Questions tagged [nested-sets]

The nested set model is a particular technique for representing nested sets (also known as trees or hierarchies) in relational databases.

From Wikipedia:

The nested set model is a particular technique for representing nested sets (also known as trees or hierarchies) in relational databases.

In the nested set model, nodes are numbered according to a tree traversal which visits each node twice, assigning numbers in the order of visiting, and at both visits. This leaves two numbers for each node, which are stored as two attributes. Querying becomes inexpensive: hierarchy membership can be tested by comparing these numbers. Updating requires renumbering and is therefore expensive. Refinements that use rational numbers instead of integers can avoid renumbering, and so are faster to update, although much more complicated.

392 questions
0
votes
1 answer

mySql force item in front of siblings in nested set

I have hierarchical data (categories) stored in a mySql database using the nested set model. All is working perfectly only I now need the ability to add a property to any node (force_to_top) which will set the node to temporarily force to the top of…
Stu
  • 4,160
  • 24
  • 43
0
votes
1 answer

php nested set, building links in navigation menu

I have a few categories in my database which I am retrieving using nested set model something like this(number in brackets represent depth): New(1) -General(2) -Console(2) Games(1) -pc(2) --emulator(3) -ps3(2) I then have a function to handle the…
ninjamaster
  • 83
  • 1
  • 6
0
votes
1 answer

Hierarchical Product Count using Nested Sets in MySQL

If I have a nested set for categories, like so: Widgets Blue Red Green and I use a relational table to reference products to these categories, e.g. Products: id name 1 Glowing Widget 2 Flying Widget 3 Exploding…
Kohjah Breese
  • 4,008
  • 6
  • 32
  • 48
0
votes
1 answer

mongodb...Mongoose update nested sets... why is this so hard arg

I'm trying to fix some data globally... Why am i getting this error...TypeError: Object function model(doc, fields, skipId) { if (!(this instanceof model)) r I am getting all the data and it should update, but its not. and the error is obtuse.…
0
votes
1 answer

MySQL Storing different nested sets in same table

I have a table that stores nested sets. It stores different nested sets differentiated by a collectionid (yes i'm mixing terms here, really should be nestedsetid). it looks somewhat like this: id | orgid | leftedge | rightedge | level |…
Jarede
  • 3,310
  • 4
  • 44
  • 68
0
votes
0 answers

Querying nested set model upside down

I've got a webshop with a tree of categories stored as a nested set tree (lft, rgt and lvl attributes for each category). What I want to do is show all categories which contains a certain type of product as a full tree. I can easily get Ids of all…
Thomas Jensen
  • 2,635
  • 25
  • 38
0
votes
1 answer

MySQL nested set non-children relationships

I have a nested set of organisations, that looks something like this (the nodes are org ids): 1234 is a parent of 4499 and 3322, but 9905 is "affiliated", not really a parent or child, to 1234. I believe that the leftedge, rightedge set up should…
Jarede
  • 3,310
  • 4
  • 44
  • 68
0
votes
1 answer

C++ XE2 - How to read Nested JSON?

I have been searching quite a while now for how to read a nested JSON with C++ Builder XE2 TJSONObject. There are a few examples in Delphi but they use the TJSONValue object, but in the C++ version this class has a pure virtual function and can not…
Max Kielland
  • 5,627
  • 9
  • 60
  • 95
0
votes
2 answers

Getting node ancestors using Doctrine 1.2 and Symfony 1.4

I've a little trouble while trying to get all ancestors from a node; This is my schema.yml: Constante: connection: doctrine tableName: constante actAs: NestedSet: hasManyRoots: true rootColumnName: parent_id columns: id: type: integer(8) …
Manuel Serrano
  • 100
  • 1
  • 4
  • 7
0
votes
2 answers

Multiple tables in nested sets hierarchy

I have a number of distinct items stored in different MySQL tables, which I'd like to put in a tree hierarchy. Using the adjacency list model, I can add a parent_id field to each table and link the tables using a foreign key relationship. However,…
jetboy
0
votes
3 answers

How to transform nested sets efficiently into a object hierarchy

Suppose I have a list of nodes which represent a nested set hierachy (examples are in pseudo c#). class Node { public decimal left; public decimal right; public decimal id; public void AddChild(Node child) {...} ... } List
sloth
  • 99,095
  • 21
  • 171
  • 219
0
votes
1 answer

Propel Nested Set in combination with Pagination

$root = AnimeCommentQuery::create()->findRoot(2); $html = "
    {$root->getComment()}"; foreach ($root->getDescendants() as $post) { $html .= '
  • '; $html .= $post->getComment(); $html .= ' by…
0
votes
1 answer

associative array to nested set

I am trying to get nested set data for an associative array. The array needs to be stored as a nested set in mysql database. Array i want to get nested set data for: Link for nested set implementation…
Dev Teem
  • 31
  • 3
-1
votes
1 answer

How to pass Controller data value in nestedset custom function in Laravel blade file

Find below the controller code and blade file code, Tested & Working Controller Code: $nodes = Category::get()->toTree(); Blade File Code Returning Value = 6 {{$data->category_id}} I need to pass this variable value inside the below traverse…
-1
votes
1 answer

How can you properly model nested set in UML?

I'm trying to model a system where I have directories with files. A directory contains files as well as directories. I found a good method to represent a tree in an SQL database…
user3260388
  • 313
  • 1
  • 4
  • 10
1 2 3
26
27