4 ms·
Agreed. An interesting alternative approach to a single 'parent' pointer in the record is the use of an ancestor table. http://www.evolt.org/working_with_hiera
by jbert 19y ago
Agreed. An interesting alternative approach to a single 'parent' pointer in the record is the use of an ancestor table.
http://www.evolt.org/working_with_hierarchical_data_in_sql_using_ancestor_tables http://www.evolt.org/working_with_hierarchical_data_in_sql_u...
This allows all children (or parents) to be fetched in a single query. A suitable "order by" clause also groups them together for easier processing in one pass.
The cost is the same as any denormalisation - additional updates and integrity issues - so it isn't a no-brainer but it's probably a win in most such situations.