Questions tagged [materialized-path-pattern]
46 questions
2
votes
1 answer
Sorting a tree while maintaining structure
I have a tree using materialized path.
The table is similar to:
+-------------+--------+----------+-------+
| path | depth | children | score |
+-------------+--------+----------+-------+
| 0001 | 1 | 3 | 5 |
|…

DanCake
- 2,003
- 4
- 23
- 29
2
votes
2 answers
How to display django-treebeard MP in template as dropdown menu?
Following the treebeard docs api example, I created an annotated_list of my tree using get_annotated_list(parent=None, max_depth=None) with parent=. I pass this to my template and using the example they attribute in the docs to Alexey…

amy
- 354
- 1
- 9
2
votes
0 answers
“Table of content” nested tree out of flat materialized paths
I have this array of paths:
[
"Shape Up.Introduction.Growing Pains",
"Shape Up.Shaping.Principles of Shaping.Wireframes are too concrete",
"Shape Up.Shaping.Principles of Shaping.Words are too abstract",
"Shape Up.Introduction.Six-week cycles",
…

Adam
- 101
- 1
- 7
1
vote
3 answers
Materialized Path PHP Regex to Select Last Item
I'm trying to get the last occurrence of an item from a materialized path. Below is a subset of possible values I've provided as an example where X, Y & Z can be any arbitrary string:
X/
X/Y/
X/Y/Z/
How can I select that last item on the path…

VinnyD
- 3,500
- 9
- 34
- 48
1
vote
0 answers
Nested Set Model vs Materialized Path in MySQL
Just getting started on my first big(ish) project using mysql with quite a limited amount of technical knowledge. I'm faced with what seems to be the very common question of how to represent my tree hierarchy. I've been through Google quite…

NallyRoll
- 370
- 1
- 8
- 20
1
vote
1 answer
Count children from hierarchy path
I have a table like this:
id
name
path
1
John
/1
2
Mark
/2
3
Kevin
/1/3
4
Sarah
/1/3/4
5
Andy
/2/5
...
...
...
So, I can say that Sarah is Kevin's child which is John's child.
I would like to have this:
id
name
path
number…

Fabio Manniti
- 151
- 12
1
vote
1 answer
Query an adjacency list in SQL via a materialized path
I have a large hierarchy (2,500+ records) stored in Microsoft SQL Server (2019) using an adjacency list model (e.g., Id, ParentId). I am looking for an efficient approach to look up a record based on a particular path in the hierarchy. In other…

Jeremy Caney
- 7,102
- 69
- 48
- 77
1
vote
1 answer
What size makes Materialized Paths impractical?
If I am expecting my table to have say, 700,000 rows,
A user can be a vanilla signup (starting a brand new tree)
or
A user can be a invited signup (starting a new branch on an existing tree).
If we are expecting these trees to get, on average, 800…

Hailwood
- 89,623
- 107
- 270
- 423
1
vote
2 answers
Creating a specific tree structure from materialized path
I have "Entities" and "Entity Templates". The top level entity is tied to an Entity Template which is the "templateId1". From there an entity is tied to another entity in a path by using its id. I'm trying to end up with the following data structure…

sturoid
- 2,501
- 4
- 20
- 36
1
vote
0 answers
How to use materialized paths data for force directed tree with python
Date structure of materialized paths is shown as below:
a node | id | parent_path
/ \ a | 42 | 42/
... b b | 63 | 42/63/
/ \ c | 84 | 42/63/84/
c d d |…

johnhsq
- 11
- 2
1
vote
1 answer
Issues with porting code from javascript to go
I have this code in JS, which converts some sort of materialized path to tree structure:
var input = [[1201], [1201,1202,1203,1204], [1201,1202,1203], [1201,1202], [1201,1205]];
var output = [];
for (var i = 0; i < input.length; i++) {
var…

asyndrige
- 572
- 6
- 23
1
vote
1 answer
How do I properly sort a materialized paths in SQL?
I am using Materialized Path to store a tree structure in SQl (MySQL 5.7 in my case). I am storing the paths as slash-separated slugs. All the tutorials I have read said to sort the rows by the path to extract it in the right order, but it appears…

Sander Marechal
- 22,978
- 13
- 65
- 96
1
vote
1 answer
How to store hierarchical data within Firebase
In SQL, I have used nested sets to store hierarchical data. I am trying to do the same with Firebase. In theory, the hierarchy could be "n" levels deep, but in actuality will probably be only 5-7 levels deep.
I have done quite a bit of research.…

spdaly
- 1,260
- 2
- 18
- 35
1
vote
2 answers
Postgres Materialized Path Search using Bookshelf
Let's say I am using materialized paths to store management chains:
Table: User
id name management_chain
1 Senior VP {1}
2 Middle Manager {1,2}
3 Cubicle Slave {1,2,3}
4 …

Abraham P
- 15,029
- 13
- 58
- 126
1
vote
1 answer
Materialized path relationship in declarative SQLAlchemy
I have a hierarchical categories model, where hierarchy is maintained using materialized path (one character per level):
class Category(Base):
__tablename__ = 'categories'
id = Column(SmallInteger, primary_key=True)
path =…

Nikita Nemkin
- 2,780
- 22
- 23