[database] [Database] Toward better databases
David Strauss
david at fourkitchens.com
Tue Jul 8 15:57:54 UTC 2008
Oh, I see. I was including implicit defaults.
However, if you have a non-null varchar, the implicit default is "". There's little to be gained from not specifying defaults and letting MySQL set the defaults unless we use the defaults data elsewhere in the abstraction system.
I do agree that removing absurd defaults is a semantic improvement.
-----Original Message-----
From: Barry Jaspan <barry.jaspan at acquia.com>
Date: Tue, 8 Jul 2008 11:26:58
To: David Timothy Strauss<david at fourkitchens.com>
Cc: Joshua D. Drake<jd at commandprompt.com>; <database at drupal.org>
Subject: Re: [database] [Database] Toward better databases
David,
On Jul 7, 2008, at 11:02 PM, David Timothy Strauss wrote:
> MySQL requires non-null defaults for non-null columns. What's the
> problem?
Ummmm.. really? My understanding is that MySQL provides implicit
default values for NOT NULL columns that are not given a default value
when not in strict mode, but that isn't the same as requiring that a
non-null default be provided.
During the D6 switch to Schema API, I tried to remove all the
unnecessary/incorrect default values on columns. For the variable
table, a default name of '' is semantically ridiculous; we should
never have a variable whose name is the empty string and there should
never be an INSERT statement into that table that does not provide a
value for name. So why have the default value at all?
Barry
>
>
> ----- "Joshua D. Drake" <jd at commandprompt.com> wrote:
>
>> On Mon, 2008-07-07 at 20:42 -0500, Larry Garfield wrote:
>>> On Monday 07 July 2008 8:44:40 am you wrote:
>>>> Howdy, everyone. Here's my current brain-dump:
>>
>>> CREATE TABLE variable (
>>> name varchar(128) NOT NULL default '',
>>> value text NOT NULL,
>>> PRIMARY KEY (name)
>>> )
>>>
>>
>> I would also note that the above is horribly bad.
>>
>> You just said that your primary key is name but that its default is
>> '',
>> that protects against NOT NULL but allows a single '' as well as a
>> single ' ' or ' ' or ' ' etc...
>>
>> Sincerely,
>>
>> Joshua D. Drake
>>
>>
>> _______________________________________________
>> Database mailing list
>> Database at drupal.org
>> http://mail.drupal.org/mailman/listinfo/database
> _______________________________________________
> Database mailing list
> Database at drupal.org
> http://mail.drupal.org/mailman/listinfo/database
More information about the Database
mailing list