You are here: Re: Better understanding of PRIMARY, UNIQUE, INDEX... « All PHP « IT news, forums, messages
Re: Better understanding of PRIMARY, UNIQUE, INDEX...

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация