Inline
Side-by-side
Side-by-side Markdown
Uses separate join table with: ancestor, descendant, depth (optional)
Cheap ancestry and descendants
Writes costs O(log n)
(size of the subtree) for insert, updates, deletes
Normalized encoding: good for RDBMS statistics & query planner in joins
Requires multiple rows per node
Column: lineage (e.g. /parent/child/grandchild/etc...)
Cheap descendants via prefix query (e.g. LEFT(lineage, #) = '/enumerated/path'
)
Writes costs O(log n)
(size of the subtree) for insert, updates, deletes
Non-relational: relies on Array datatype or serialized string format
Like nested set, but with real/float/decimal so that the encoding isn't volatile (inexpensive move/insert/delete)
Has real/float/decimal representation/precision issues
Matrix encoding variant adds ancestor encoding (materialized path) for "free", but with the added trickiness of linear algebra.
General summary
2008 offers HierarchyId data type that appears to help with the Lineage Column approach and expand the depth that can be represented.
Uses separate join table with: ancestor, descendant, depth (optional)
Cheap ancestry and descendants
Writes costs O(log n)
(size of subtree) for insert, updates, deletes
Normalized encoding: good for RDBMS statistics & query planner in joins
Requires multiple rows per node
Column: lineage (e.g. /parent/child/grandchild/etc...)
Cheap descendants via prefix query (e.g. LEFT(lineage, #) = '/enumerated/path'
)
Writes costs O(log n)
(size of subtree) for insert, updates, deletes
Non-relational: relies on Array datatype or serialized string format
Like nested set, but with real/float/decimal so that the encoding isn't volatile (inexpensive move/insert/delete)
Has real/float/decimal representation/precision issues
Matrix encoding variant adds ancestor encoding (materialized path) for "free", but with added trickiness of linear algebra.
General summary
2008 offers HierarchyId data type appears to help with Lineage Column approach and expand the depth that can be represented.
Uses separate join table with ancestor, descendant, depth (optional)
Cheap ancestry and descendants
Writes costs O(log n)
(size of the subtree) for insert, updates, deletes
Normalized encoding: good for RDBMS statistics & query planner in joins
Requires multiple rows per node
Column: lineage (e.g. /parent/child/grandchild/etc...)
Cheap descendants via prefix query (e.g. LEFT(lineage, #) = '/enumerated/path'
)
Writes costs O(log n)
(size of the subtree) for insert, updates, deletes
Non-relational: relies on Array datatype or serialized string format
Like nested set, but with real/float/decimal so that the encoding isn't volatile (inexpensive move/insert/delete)
Has real/float/decimal representation/precision issues
Matrix encoding variant adds ancestor encoding (materialized path) for "free", but with the added trickiness of linear algebra.
General summary
2008 offers HierarchyId data type that appears to help with the Lineage Column approach and expand the depth that can be represented.