Found in 1 comment on Hacker News
iamelgringo · 2010-05-30 · Original thread
Threaded comments are surprisingly difficult to model in a relational database. I spent about a month on the problem when I rolled my own threaded comment system for newsley. Relational Databases really don't lend themselves to easily modeling tree structures.

If you're interseted in doing something like this, I'd highly recommend this book:

He has two really good chapters that specifically building a comment system. It takes a bit of work, and you end up pre-computing the comment system on INSERT's instead of SELECT's. But, you can build a comment system that pulls your entire comment tree in order using a single SELECT ... FROM COMMENTS ... ORDER BY comment.node_left;

Fresh book recommendations delivered straight to your inbox every Thursday.