Jump to content

primary key


ohdang888

Recommended Posts

i came across an error in mysql ...

#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

 

so that means on the "id" column can be used a a primary key. But i want to use "link" as the key because thats what i'll be doing all my queries with....

 

does anyone know what to do with this?

Link to comment
Share on other sites

The error message doesn't say there can be only one key and it doesn't say "id" has to be the primary key

 

Integer key fields are more efficient than varchar fields, but if link is unique, you can make that the primary key and not have the id field. But if you need link as a foreign key in other tables then it is going to be duplicated in those, taking far more space than an id would

Link to comment
Share on other sites

I'm creating a commenting system. and when users go to "example.php?id=5", it will search for all comments that have "5" under the column "page", so "page" will be used the most as a search query.

 

But its not always unique, there could be 1 comment with "5" or, there could be 40..

 

so would it still be more efficient to use "page" as the key.

Link to comment
Share on other sites

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.