christianmlong + hierarchy   20

Storing Hierarchical Data in a Database — SitePoint
Whether you want to build your own forum, publish the messages from a mailing list on your Website, or write your own cms: there will be a moment that you’ll want to store hierarchical data in a database. And, unless you’re using a XML-like database, tables aren’t hierarchical; they’re just a flat list. You’ll have to find a way to translate the hierarchy in a flat file.

Storing trees is a common problem, with multiple solutions. There are two major approaches: the adjacency list model, and the modified preorder tree traversal algorithm.
database  mptt  tree  hierarchy  algorithm  sql 
april 2019 by christianmlong
Overview — django-mptt 0.8.6 documentation
What is Modified Preorder Tree Traversal?

MPTT is a technique for storing hierarchical data in a database. The aim is to make retrieval operations very efficient.

The trade-off for this efficiency is that performing inserts and moving items around the tree is more involved, as there’s some extra work required to keep the tree structure in a good state at all times.
django  database  plugin  mptt  tree  hierarchy 
april 2019 by christianmlong
FlatBuffers: Main Page
FlatBuffers is an efficient cross platform serialization library for C++, C#, C, Go, Java, JavaScript, PHP, and Python. It was originally created at Google for game development and other performance-critical applications.
programming  serialization  library  hierarchy  python  google 
october 2016 by christianmlong
jsTree
jsTree is jquery plugin, that provides interactive trees. It is absolutely free, open source and distributed under the MIT license. jsTree is easily extendable, themable and configurable, it supports HTML & JSON data sources and AJAX loading.

jsTree functions properly in either box-model (content-box or border-box), can be loaded as an AMD module, and has a built in mobile theme for responsive design, that can easily be customized. It uses jQuery's event system, so binding callbacks on various events in the tree is familiar and easy.

Just a few of the features worth noting:

drag & drop support keyboard navigation inline edit, create and delete tri-state checkboxes fuzzy searching customizable node types
javascript  jquery  plugin  json  hierarchy  tree  represent  ui  web  development 
october 2016 by christianmlong
Python: import module from another directory at the same level in project hierarchy - Stack Overflow
In summary, the hierarchy I would use is:

user_management (package)
|
|------- __init__.py
|
|------- Modules/
| |
| |----- __init__.py
| |----- LDAPManager.py
| |----- PasswordManager.py
|

Scripts/ (*not* a package)
|
|----- CreateUser.py
|----- FindUser.py

Then the code of CreateUser.py and FindUser.py should use absolute imports to import the modules:

from user_management.Modules import LDAPManager

During installation you make sure that user_management ends up somewhere in the PYTHONPATH, and the scripts inside the directory for executables so that they are able to find the modules.
python  path  absolute  relative  import  filesystem  structure  hierarchy  package 
august 2016 by christianmlong
PostgreSQL: Documentation: 9.1: WITH Queries (Common Table Expressions)
Recursive queries are typically used to deal with hierarchical or tree-structured data. A useful example is this query to find all the direct and indirect sub-parts of a product, given only a table that shows immediate inclusions:

WITH RECURSIVE included_parts(sub_part, part, quantity) AS (
SELECT sub_part, part, quantity FROM parts WHERE part = 'our_product'
UNION ALL
SELECT p.sub_part, p.part, p.quantity
FROM included_parts pr, parts p
WHERE p.part = pr.sub_part
)
SELECT sub_part, SUM(quantity) as total_quantity
FROM included_parts
GROUP BY sub_part
postgres  sql  tree  hierarchy  parent  child  query  recursive 
september 2015 by christianmlong
sql server 2005 - SQL Query for Parent Child Relationship - Stack Overflow
with [CTE] as (
select * from [TheTable] c where c.[ParentId] = 1
union all
select * from [CTE] p, [TheTable] c where c.[ParentId] = p.[NodeId]
)
select * from [CTE]
sql  tree  parent  child  hierarchy  query 
september 2015 by christianmlong
The simplest(?) way to do tree-based queries in SQL (dirtSimple.org)
by adding a "closure" table with fields for "parent", "child", and "depth", you can represent the hierarchy to whatever depth is present. So, if directory C is a child of directory B, and directory B is a child of A, then the base table would look like this:
id parent_dir name
1 0 A
2 1 B
3 2 C

And the closure table would look like this:
parent child depth
1 1 0
2 2 0
3 3 0
1 2 1
2 3 1
1 3 2

In other words, the closure table says, "A is a child of itself at depth 0", "B is a child of A at depth 1", and "C is a child of A at depth 2". The total number of records in the closure table is equal to the number of records in the base table, times the average depth of the tree(s) in the base table. (That is, each base table row has a row in the closure table, plus one row for each of its parents.)
hierarchy  tree  sql  parent  child 
september 2015 by christianmlong

Copy this bookmark:



description:


tags: