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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:38:02+00:00 2026-05-26T00:38:02+00:00

I am interested in designing the database (well, I’m only concerned about one table

  • 0

I am interested in designing the database (well, I’m only concerned about one table really) for a site with the following requirements:

  1. There is an items page, which lists items. items.xyz?id=t displays the item with ID t. I need the IDs of the items to be consecutive. The first item has ID 1, the second ID 2 and so on. Each item page has comments on that item.
  2. There are other pages, such as objects, where objects.xyz?id=t displays the object with ID t. The IDs here need not necessarily be consecutive (and they can overlap with item IDs, but it’s ok if you suggest something that forces them not to overlap). These also have comments.

My question is how to design the Comments table? If I have an EntityID in it that represents the page the comment should be displayed on (be it an item page or an object page), then should I make it so that the ItemID never overlaps the ObjectID by making all ObjectID start from, say, 109 and using a GUID table? (The ItemIDs increase very slowly). Is this acceptable practice?

Right now I’m doing it by having a bunch of nullable boolean fields in each comment: IsItem, IsObjectType1, IsObjectType2, …, which allows me to know where each comment should be displayed. This isn’t so bad since I only have a few objects, but it seems like an ugly hack.

What is the best way to go about this?

  • 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-26T00:38:03+00:00Added an answer on May 26, 2026 at 12:38 am

    I see three solutions (assuming it is impossible or undesired to put Pages and Objects in one table). Either:

    1. Tell the comment which it belongs to by giving it two columns: PageId and ObjectId.
      That way you can also give these columns foreign keys to the respective tables and add proper indexes.

    2. Introduce a table ‘Entity’ that has a unique id, a PageId and an ObjectId. Either columns are optional off course, exactly one of them must be filled, not 0 or both.
      This way, you move all the potential garbage of having separate entities to this table, not polluting the Comments table, which should contain just comments. You isolate the mess.

    3. Create a link table between Comments and Items and another table between Comments and Objects. Items and Objects are completely unrelated, and you don’t have to pollute the Comments table with a lot of NULL values in multiple columns. When you create a comment, you decide if it links to an Item or an Object by inserting a link in either ItemComments or ObjectComments. Reading comments for an item or object is a matter of two simple joins.

    The comments table can then contain only a single EntityId that refers to the Id in the Entity table.

    The big advantage to this approach is twofold:
    a) You can link other things to the same table too, whichout much hassle.
    b) You can add other kinds of Entities and they will automatically support Comments and other things you might add, as mentioned in a).

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

Sidebar

Related Questions

I've been designing a card game in Java on Windows. It runs really well
There are tons of good papers about designing and developing for security (and even
There is a lot of information out there about designing and implementing a compiler,
I'm designing an interface to display sets of data. I'm interested in organizing the
Interested if anyone has used VSTS Database Edition extensively and, if so, which features
I'm interested in learning some (ideally) database agnostic ways of selecting the n th
I'm designing a new DataBase that at the moment has 50 Tables. For many
I am designing a dynamic site for some form of weather data, which I
I've been designing a site over the past couple days, and been doing some
I am interested in improving my designing capability (designing of classes with its properties,

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.