dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Database architecture and queries

  1. #1
    Join Date
    Oct 2006
    Posts
    364

    Database architecture and queries

    Hi,

    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:

    http://failblog.org/2008/12/09/pengwin/#comments

    The way I'm doing it now with while loops is very inefficient.
    Thanks.

  2. #2
    Join Date
    Nov 2008
    Posts
    25
    database structure should be (at bare minimum):
    comment_id int
    comment_parent_id int (should be default 0 for comments that are the top of a thread)
    comment_text text

    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).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles