[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ProgSoc] NULL values in primary keys in MySQL



On Sun, Jun 04, 2006 at 12:10:08AM +1000, arp wrote:
> On Sat, Jun 03, 2006 at 11:54:48PM +1000, jedd wrote:
> >  I understand it's bad design, and I get that what I probably want
> >  is a unique key rather than a primary one, and I get that I should
> >  read up (again) on normalisation, and I'm well aware that NULL
> >  != NULL  ... but all that aside (and AFAIK that all *is* an aside)
> >  what's the logical, or even technical reason for why you can't have
> >  a primary key that contains columns that may contain a NULL entry?
> 
> Because a primary key requires all keys to be of a unique value and a
> NULL does not mean anything other then (effectively) unset, unknown or
> words to similar effect. In essence it is not actually a value and as
> such it can't be compared to a value in order to test for uniqueness.

Actually, another reason (and possibly better explanation) is that keys
are meant to uniquely identify a row of data. How will you identify a
single row if you have two+ rows with NULL as their primary key?

arp the sleepy

-
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to progsoc-request@xxxxxxxxxxxxxxxxxxx
If you are having trouble, ask owner-progsoc@xxxxxxxxxxxxxxxxxx for help.