News for hackers. Stuff that matters.
Re:Ask YC: what's the best way to model a threaded comment s... by jbert on Monday March 17, 2008 @09:11AM (#138888)
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_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.

There are no comments on this comment yet.