Jump to content

Recommended Posts

I have many tables - users, notes, news, etc - each with their own unique id to connect to one another (the usual stuff). I want to add a commenting system to the service. So if someone wants to comment on a news article or a picture etc, it is all contained within one table system.

 

I thought that I would add an 'object' table that is the global unique id master. So if I were to add an user, they would get a user_id and object_id, and likewise for just about anything else that gets inserted into one of the database tables.

 

I figured this would be the cure for the commenting system, you have a comment_id and then you connect it to an object_id. and when the page is generated, a check against the commenting system and object_id would display comments...

 

Does this make sense? Would there be a better way to handle this? If I were to go this route, how large could that object table get - it would be handing out object_id's for N tables?

 

Thanks

Another way you can do it is have your main object table and have that dictate what your sub-table id's are...then you really have 1 unique id to worry about

 

objects:

id    type

1    user

2    note

3    news

4    user

5    comment

 

users:

id    name

1    test1

4    test2

 

notes:

id    title

2    this is a test

 

and so on...

 

...hope that makes sense :) It seems like this would keep you a little more organized and not worrying about more then 1 id.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.