4 ms·
Someone posted a thread the other day about good ways to store threaded discussions. Store it like: 1 1.1 1.1.1 1.2 2 2.1 2.2 etc. And load it in one
by ErrantX 18y ago
Someone posted a thread the other day about good ways to store threaded discussions.
Store it like:
1
1.1
1.1.1
1.2
2
2.1
2.2
etc.
And load it in one database query ( id > x AND id < y or w/e) then traverse through it. easy.
EDIT: I would handle deleted like you suggest.
- mixmax 18y agoThere are a few problems with this approach IMHO: - If the discussion is sorted by something else than the counter, karma for instance, it isn't quite as easy. - When you're moving posts you need to look at all the children and make changes ccordingly. This might not be a huge problem in itself, but there are problematic edge cases. What if someone makes a rely to a thread that has just been moved for instance? It would get archived wrong. - If you want to encapsulate a post and it's children (if for instance you want to be able to hide children w. javascript) you need to write out the HTML using a recursive algorithm. Besides, it doesn't seem like a very elegant solution ;-)
- swolchok 18y ago"- If the discussion is sorted by something else than the counter, karma for instance, it isn't quite as easy." ORDER BY karma?