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 6659161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:59:58+00:00 2026-05-26T01:59:58+00:00

I have a comments section on a website i’d like to streamline a bit

  • 0

I have a comments section on a website i’d like to streamline a bit if possible so it’s not as much of an impact on the database. When a user selects a post, and if it has comments associated with it, it lists the comments. when the comments list, it fetches the username from another table. I store the id for the user in the comments table, and use that id to select the record from the users table. and displays as “user” said:

lets say i have 1000 comments on a post, it will hit the users table 1000 times to grab user names. I think this is probably a bad design. i thought of a few solutions, but don’t know what would be recommended in this situation.

should i just be storing the username inside the comments table?

should i store all of the usernames already called in a session array?

put all of the usernames in a file, and call from the file?

or is there another solution that i haven’t thought of?

i’m kind of confused. I thought i was doing the right thing by using the IDs in the comment table, and then using it to fetch the username, but after reading about a million posts on using less impact on the database, i’m starting to question myself.

WOW, thanks for all of the useful answers. here is the table scheme, i don’t know why i didn’t put in in originally.

comments table for jokes:

id | author_id | joke_id | date_created | body
---+-----------+---------+--------------+-----
1  |     3     |    2    | 2011-06-12   | this is a comment

and for the users:

id | user_name | password | email | date_joined | visible
---+-----------+----------+-------+-------------+---------
 3 |   booboo  | password | email | todays_date |    1
  • 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-26T01:59:58+00:00Added an answer on May 26, 2026 at 1:59 am

    This is what JOINs are for – so that you can run a single query and efficiently get the combined information from multiple tables. E.g.:

    SELECT comments.id, comments.content, users.name
    FROM comments
    JOIN users ON comments.user = users.id
    WHERE comments.id in (1,2,3)
    

    would look up the 3 comments with id 1, 2, and 3, plus also get the username of each commenter, and return rows that looked like this:

    comments.id | comments.content  | users.name
    ------------+-------------------+---------
    1           | "First comment."  | "Poster1"
    2           | "Second comment." | "Poster2"
    3           | "Third comment."  | "Poster3"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple website, and would like to create a 'Comments' section
I want to have a comments section in my app that looks like this:
I have a Pictures section on my website and allow users to enter comments
I want to have a comments section in my app that looks like this:
I'd like to have comments in my code, but I want them to be
What language(s) have comments with side effects? In essence, comments which are not comments....
How to automatically format PhpDoc comments in Netbeans? I'd like to have comments aligned
as per the title; is it possible to have nested comments in valid HTML?
I have recently added a comments section to a blog. Codeigniter says to always
I'm at a loss to for a solution to my comments section not showing

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.