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
0
votes
0 answers

etrepat/Baum working with two tables

I'm trying to use Baum with two tables but I am not able to implement. My intention is to have a table to store the category information as id, name, slug and status and normal Baum table with foreign key category_id. In cadegoria the registration'm…
0
votes
0 answers

Querying a tree structure for getting its children

I have a tree (nested set) table composed by persons in an organization. Each person has a rank in the organization. I'm trying to form a query that will get me the down line (children) for a person (all persons under that person) except if they are…
Ismael LR
  • 79
  • 1
  • 9
0
votes
1 answer

Count of items by depth with a nested set model

I'm using the nested set model for my database (from here: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/), it works perfectly, but... From the "Depth of a Sub-Tree" request, I want an other result. Initial…
Surfoo
  • 88
  • 1
  • 12
0
votes
2 answers

CONCAT all parents of category

Sample database (Categories in a Nested Set Model): CREATE TABLE `category` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL DEFAULT '', `lft` int(11) NOT NULL, `rgt` int(11) NOT NULL, PRIMARY KEY (`id`) )…
0
votes
1 answer

Suggestions modelling nested data sets that change over time

I am looking for suggestions on creating a temporal nested data set model. I am trying to improve performance for reading sections. I have a node tree of ~1million nodes, with frequent depths of 20+ nodes. The tree stores categories that can change…
AndrewP
  • 1,598
  • 13
  • 24
0
votes
0 answers

Nested Set or Adjacency List Model for file permissions (MySQL)

Question: What design should one use when storing all user file/folder permissions in a MySQL database? Details: I am having trouble deciding whether Nested Set requires far too much insert time or whether Adjacency list requires too much access…
puk
  • 16,318
  • 29
  • 119
  • 199
-1
votes
2 answers

Creating lft and rgt columns dynamically in MySQL

Can anyone guide me on how to create the lft and rgt columns (parsed from left to right in a tree from root)dynamically for a table using MySQL Query? The structure of my table looks like this: id----name----parent_id and I want the structure like…
Sagnik
  • 1,446
  • 1
  • 9
  • 13
1 2 3
4