Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6788075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:26:29+00:00 2026-05-26T17:26:29+00:00

The common normalized structure of database for a forum is to store all posts

  • 0

The common normalized structure of database for a forum is to store all posts in a table where a column define the thread number. To display a thread, we need to perform SELECT with WHERE clause for the thread number (sorted by date). In this case, we deal with a very long table for every query.

Is it really the best way to store posts and threads for a forum?

It is more complicated for a Q&A like stockexchange projects, as in addition to answers (i.e. identical to posts in forum), each answer can have comments.

What is the most efficient database structure for a large website like stackoverflow?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:26:30+00:00Added an answer on May 26, 2026 at 5:26 pm

    It’s far from being as large as SO, but in my application, the model I chos was to have each post have

    • a FK to its parent post (root posts have null in this column)
    • a FK to the root post (root posts have their own ID in this column, which is a bit awkward to insert new root posts, but helps for queries)
    • a FK to their forum

    This allows getting easily

    • the root posts of a forum (searching for posts with a null parent)
    • all the messages in a thread at once (searching all the posts having a given root)
    • presenting the thread in flat mode (per date) or in tree mode (since each post knows its parent)
    • the last posts in a given forum (searching the latest post grouped by forum)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A common problem I got in Haskell is to extract all terms in a
CTE (Common Table Expression) vs Temp tables or Table variables , which is faster?
What's a common/best practice for database design when it comes to improving performance on
Common question but I could use an english explanation. Is it like Java where
Common scenario: I have a library that uses other libraries. For example, a math
Common problem I'm sure, but I can't figure it out. In my AndroidManifest.xml and
Common situation: I have a client on my server who may update some of
A common task in programs I've been working on lately is modifying a text
A common pattern in C++ is to create a class that wraps a lock
DocumentsController#common_query can handle multiple different request styles. i.e. all docs in batch 4 or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.