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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:20:38+00:00 2026-05-22T16:20:38+00:00

I have 3 database tables and I need to normalize them. The association between

  • 0

I have 3 database tables and I need to normalize them. The association between tables like this:

Tables:
1. question
2. answers
3. comments

  • (question can contain many answers and many comments)
  • (answers can contains many comments)

I know I could use questions and answers in one table and then I solve the problem, but I want to use it this way, so what’s the best way to associate ‘comments’ with ‘questions’ and ‘answers’?

I tried to put question id and answer id into the table of comments and use only one of them for each row, is this right? this way I can use them in php script but I don’t know if there is another better way because that I asked.

Thank you.

  • 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-22T16:20:39+00:00Added an answer on May 22, 2026 at 4:20 pm

    I would set them up as follows:

    Posts (both Questions and Answers would be types of "Posts"):
    Post_ID
    [Fields Common to Posts, e.g. "Post_Content", "Poster_ID", "Post_TimeStamp" etc.]
    
    Questions:
    Question_ID
    Post_ID
    [Question-specific fields, e.g. "Question_Title"]
    
    Answers:
    Answer_ID
    Post_ID
    [Answer-specific fields]
    
    Comments:
    Comment_ID
    Post_ID
    [Comment fields]
    

    The main idea of having a seperate Posts table is to normalize your database, and allow for a logical structure for comments to point to both. Like APC commented, it also gives you a good setup for developing your site/database going into the future (when you might want other types of commentable “Posts.”

    While the enum method listed below would work, it’s not good database design. In general, I would suggest only using ENUMs when you’re representing a real world list of items.. not for organizing your database structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySql database with three tables I need to combine in a
I have a database two tables and a linking table that I need a
I have a need to sync auto_increment fields between two tables in different databases
I have 3 database tables, all of them have the same 5 columns. They
I have two database tables, users and logs. I need SQL code to do
I have database of about 5 tables. I am going to need to get
I have a large database table that I need to display on a Windows
I have a database table with a field that I need to read from
I have a MySQL database, and a particular table in that database will need
I have a name of table or view in PostgreSQL database and need to

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.