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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:36:51+00:00 2026-05-17T23:36:51+00:00

Assume you want to build a database for some web application. This database already

  • 0

Assume you want to build a database for some web application. This database already contains many tables and you might have to extend it in the future.

Also, you want the end user to be able to comment any kind of object in the database.

I would like to find a solution for this would be generic enough so that I don’t have to extend it each time I add a new table in the database.

I thought of the following:

Table Name: comment

columns:

  • id : the id of a comment
  • user_id : the id of the user making the comment
  • object_table_name : the table where the commented object is
  • object_id : the id of the commented object in the object_table_name table.
  • text : the text
  • date : the date

This table sort of solve my problem, the only thing that troubles me is that the relational aspect of it is rather weak (I can’t make object_id a foreign key for instance).
Also if some day I need to rename a table I will have to change all the concerned entries in the comment table.

What do you think of this solution ? Is there design pattern that would help me out ?

Thanks.-

  • 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-17T23:36:51+00:00Added an answer on May 17, 2026 at 11:36 pm

    Isn’t that cleaner ?

    table comment_set

    • id

    table comment

    • id
    • comment_set_id -> foreign key to comment_set
    • user_id
    • date
    • text

    existing table foo

    • …
    • comment_set_id -> foreign key to comment_set

    existing table bar

    • …
    • comment_set_id -> foreign key to comment_set
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume that we have N erlang nodes, running same application. I want to share
DTO I'm building a Web application I would like to scale to many users.
This might sound super crazy but I really want to know if this can
I want to implement search functionality for a website (assume it is similar to
Assume a table structure of MyTable(KEY, datafield1, datafield2...) . Often I want to either
Let's assume I'm a complete lazy bum and I don't want to invest the
(assume php5) consider <?php $foo = 'some words'; //case 1 print these are $foo;
Assume I have a class foo, and wish to use a std::map to store
I've got an application that uses overridePendingTransition to do some custom animations upon transitioning
I a new to django and python. I have however managed to build a

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.