|
Posted by -Lost on 07/05/06 01:22
Hrmm... my current installation of MySQL tells me:
PRIMARY and INDEX keys should not both be set for column `field`
....and actually, all I did was add the field as a UNIQUE (it was already PRIMARY).
However, it tells me this too if I try and add it as INDEX.
Is that the desired behavior?
In one aspect, I wish for all articles (for example) to have a simple numeric ID.
Therefore, I use it as a PRIMARY for incrementing. However, if ever I clean the table or
mess up with code, I do not want to give it the ability to write an ID that already exists
(right, always check with the code beforehand, but in case I did not). Which is what I
thought making it UNIQUE gave me easier control of.
I see more and more that writing small to medium intranet applications has made me
increasingly numb to the effects of database effeciency. Quite frankly, I never played
with UNIQUE or INDEX until I read this thread. I always used PRIMARY, and did the proper
checking of unique et cetera, with code.
As a last aside, what would you give as an example for all three? INDEX, PRIMARY, and
UNIQUE? (Example/sample table structure.) Thanks!
-Lost
[Back to original message]
|