
May 9th, 2008, 04:38 AM
|
|
Registered User
|
|
Join Date: May 2008
Posts: 5
Time spent in forums: 31 m 51 sec
Reputation Power: 0
|
|
|
A column of unique nums: primary key or index?
Of the importance of primary key: could I just populate it with data, if that data is what I'm going to be doing my queries with anyways? (and of course, it's all uniques)
My scenario: first column is an int(11) primary key, auto_increment. I made it this way because all the practice examples I've faced so far, have made it this way.
The second column is called 'uid' and is made up of unique medint numbers that identify my data. Every column after that is just attributes (dates, times, yes/no, etc)
When I do any select/update/insert, it's always to 'uid' and not the primary key (labeled 'id').
So should I redo my table and make the primary key be filled with my unique medint numbers instead? Wouldn't that speed up queries a little bit? Also, these numbers do not get inserted sequentially... For instance, row #2 will have a uid of 1000 and row #3 could be 500 and row #4 could be 2000.
And if I do use uid as primary key and delete the id column, should I still declare this new primary key to be auto_increment?
Thanks
|