Has anyone implemented a closure table with triggers 
<http://dirtsimple.org/2010/11/simplest-way-to-do-tree-based-queries.html> 
approach 
to hierarchy (specifically for a Bill of Materials (BOM) pattern) in 
Web2Py's DAL?

I've seen Massimo's implementation of Preorder Traversal which doesn't work 
for BOM patterns where there are multiple roots. The Adjacency Table method 
is slow for large trees.

In a Bill of Materials situation 
<http://www.vertabelo.com/blog/technical-articles/identifying-the-bill-of-materials-bom-structure-in-databases>,
 
there are multiple roots in the main table, like this:

db.define_table('item',
    Field('name', type='string', length=128, label=T('Name')))

db.define_table('bill_of_materials',
    Field('parent_item_id', type='reference item', notnull=True, 
label=T('Parent Item')),
    Field('child_item_id', type='reference item', notnull=True, 
label=T('Child Item')),
    Field('quantity', type='decimal(8,2)', default='1.0', 
label=T('Quantity')))


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to