Database architecture and queries
can anyone give me a basic scope of architecture for a database holding comments, in which some reply to others, and then the theory behind the query so that the comments are displayed like:
The way I'm doing it now with while loops is very inefficient.
database structure should be (at bare minimum):
comment_parent_id int (should be default 0 for comments that are the top of a thread)
You'll still need to loop through, but the most efficient way to do this would be to select all the top-level thread IDs first (just the comment_id field), then loop through that result-set and select the comments that are children of that thread (and so on and so forth till you get through all the layers).
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)