On Wed, Nov 30, 2011 at 1:15 PM, Ian Clelland <clell...@gmail.com> wrote:

> On Wed, Nov 30, 2011 at 12:40 PM, Kääriäinen Anssi <
> anssi.kaariai...@thl.fi> wrote:
>
>> """
>> Is this referring exclusively to natural, or user-specified primary key
>> columns? Despite Luke's reference to nullable primary keys (are these even
>> allowed by SQL?), a common idiom for copying objects is this:
>> """
>>
>> Not allowed by SQL specification, but many databases do allow them
>> (source wikipedia).
>>
>
> /me runs off to go correct Wikipedia ;)
>
> I checked the Wikipedia article on Primary Key first, and didn't see that,
> but I did note this:
>
> A table can have at most one *primary key*, but more than one unique key.
>> A primary key is a combination of columns which uniquely specify a row. It
>> is a special case of unique keys. One difference is that primary keys have
>> an implicit NOT NULL constraint while unique keys do not.
>
>
> Also, this, from http://dev.mysql.com/doc/refman/5.5/en/create-table.html:
>
>  A PRIMARY KEY is a unique index where all key columns must be defined as
>> NOT NULL. If they are not explicitly declared as NOT NULL, MySQL declares
>> them so implicitly (and silently).
>
>
> And from
> http://www.postgresql.org/docs/8.4/static/ddl-constraints.html#AEN2338:
>
> Technically, a primary key constraint is simply a combination of a unique
>> constraint and a not-null constraint.
>
>
> Oracle:
> http://docs.oracle.com/cd/B19306_01/server.102/b14200/clauses002.htm:
>
> A primary key constraint combines a NOT NULL constraint and a unique
>> constraint in a single declaration. That is, it prohibits multiple rows
>> from having the same value in the same column or combination of columns and
>> prohibits values from being null.
>
>
>

SQLite, of course, is special (http://www.sqlite.org/lang_createtable.html):

According to the SQL standard, PRIMARY KEY should always imply NOT NULL.
> Unfortunately, due to a long-standing coding oversight, this is not the
> case in SQLite. Unless the column is an INTEGER PRIMARY KEY SQLite allows
> NULL values in a PRIMARY KEY column. We could change SQLite to conform to
> the standard (and we might do so in the future), but by the time the
> oversight was discovered, SQLite was in such wide use that we feared
> breaking legacy code if we fixed the problem. So for now we have chosen to
> continue allowing NULLs in PRIMARY KEY columns.


But,


> Developers should be aware, however, that we may change SQLite to conform
> to the SQL standard in future and should design new programs accordingly.


I would consider Django 1.4+ to fall under the "new programs" umbrella :)

-- 
Regards,
Ian Clelland
<clell...@gmail.com>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to