Questions tagged [nested-set-model]

Nested Set is a method for saving hierarchical data in a relational database

Nested Set is a method used to save hierarchical data in a relational database like MySQL, Postgresql, Oracle, etc ... The term is coined by Joe Celko in his book "Trees and Hierarchies in SQL"

Nested set also goes by the term "Modified Preorder Tree Traversal".

http://en.wikipedia.org/wiki/Nested_set_model

52 questions
1
vote
1 answer

Yii Extension - nestedsetbehavior not saving

I'm trying to save a node with the extension "NestedSetBehvaior": http://www.yiiframework.com/extension/nestedsetbehavior/ But it is not saving anything in the database.. I tried using the schema that comes with the extension…
karlingen
  • 13,800
  • 5
  • 43
  • 74
1
vote
1 answer

What is best way to store hierchical data in Mysql for more than one root?

i have read so many blogs and links to save the hierarchical data in mysql database like nested set modal *Transitive Clousure Modal* Child Parent Hierchy . but i am little bit confuse can any body please suggest me what is the best method to store…
Ajay Patel
  • 791
  • 11
  • 24
1
vote
1 answer

Sorting items in MPTT result set?

I'm using the MPTT (modified preorder tree traversal) model to store hierarchical data in my MySQL table. (MPTT model: another description is nested set model.). My question is this: has anyone figured out a clever way to sort the results of a query…
Paul d'Aoust
  • 3,019
  • 1
  • 25
  • 36
1
vote
0 answers

Find first available node in Nested set model mysql

i'm new to nested set model and trying to find the first available node in a tree starting from top to bottom and left to right. each parent node can have 3 child node and i have to find the next available free node. Table mem fields m_id,lft,rgt so…
1
vote
1 answer

NSPredicate on nested object / NSSet to filter the result during NSFetchRequest

I want a simple predicate that returns me all the groups which have mode = 0 and the mode of the enrollments in the group = 0 To be precise i need a predicate to access the nested object properties. Somehow a predicate like: [NSPredicate…
yunas
  • 4,143
  • 1
  • 32
  • 38
0
votes
1 answer

Setting up a nested set hierarchy

Let's say I have a bunch of businesses. And each business can have multiple categories, subcategories and sub-subcategories (three levels). Let's say I set up a table according to the nested set model for my categories. How do I now use this table…
Shaan
  • 863
  • 2
  • 12
  • 25
0
votes
1 answer

Django - DRF ManyToMany and ForeignKey

I am building an api for entertainment management. The user can create empty project or projects with show, tour and festival. User can also create show and specify project id. A project can contain: Show 0 to * Tour 0 to * Festival 0 to * A Tour…
0
votes
0 answers

Very slow query result when using kalnoy/nestedset package - Laravel 8

I am using kalnoy/nestedset package (https://packagist.org/packages/kalnoy/nestedset) to store categories and sub-categories in a hierarchical structure. I have at max 5 levels deep hierarchy (mostly 3 levels). When I run the query…
0
votes
1 answer

When I am building nested sets, how do I get the right hand value of a non-leaf node

I'm trying to use a non-recursive depth-first-search approach to read directories and build nested sets. I need to assign left, right, and depth values to the path of the given directory(Files at the same directory level are in no particular…
0
votes
0 answers

Mysql 'nested set' method for hierarchical data returns wrong parent name in -some- rows

I have the following 'nested set' data in a table. ID name lft rgt main 1 Occasion…
Jeroen Swets
  • 215
  • 1
  • 6
  • 17
0
votes
1 answer

how to get the new value of document after updating each time in nodejs loop?

I'm trying to update collection many times in a loop but each time I get the value of oldRight not changed it gives the first value always. I'm storing topics in mongodb using nested sets pattern. for(let name of level1) { …
0
votes
1 answer

Generating a Nested Set Model from a POJO

I have been playing around with some Nested Set Models (NSM). One thing I wanted to do is to be able to generate a NSM from a given JavaScript object. For example, given the following object: var data = { Clothes: { Jackets: { …
Fraser
  • 15,275
  • 8
  • 53
  • 104
0
votes
0 answers

Delete multiple records at sametime with Nested Set Model

i'm trying to create deleted trigger for my sql server database. After a record was deleted, the trigger execute and update left, right,... of other nodes in tree. Detail about Nested Set Model. Here's my sql code for deleted trigger: ALTER…
MaybeNextTime
  • 561
  • 5
  • 11
0
votes
1 answer

SQL query for inserting a new node in a table using the nested set model fails to execute

I'm currently working with the nested set model and i've read the article from the MySQL site (Managing Hierarchical Data in MySQL). I got the following query directly from the article: LOCK TABLE categories WRITE; SELECT @myRight := right FROM…
Melvin
  • 547
  • 2
  • 10
0
votes
1 answer

How to perform bulk insert into database when model is a nested set?

I have a model involving nested set data structure, so I have used act_as_nested_set gem. Now, I have a requirement of bulk inserting more 100 thousand records. If it was not nested set data structure, bulk insertion could have been easier and…
mukesh4139
  • 76
  • 9