[Nottingham] SQLite and 'locking'

Martin martin at ml1.co.uk
Tue Feb 27 11:36:44 GMT 2007


Martin Garton wrote:
>> Except when they return bad data.  Consider the following very
>> reasonable looking query to determine how many seats are not booked:
>>
>>   SELECT COUNT(booked_by)
>>   FROM   seats
>>   WHERE  booked_by IS NULL
>>
>> In most databases, that will always return 0 regardless of how many
>> seats are or are not booked but it's easy for a developer to make that
>> mistake.
> 
> That seems obvious to me and should return 0.  ...

>> the poor developer reading the database code
>> has no way of knowing what NULL means.  Was the seat not booked?  Was
>> it booked by we do not know by whom?  Is there a bug in the code?  I am
>> constantly trying to stamp out bugs in a horrid database caused by
>> allowing NULL values in it.
> 
> I agree that when you allow NULL you have to be clear about what it
> means.  In this case, everything is fine if you define it to mean "the
> seat has not been booked"

Is not the question then:

Has the seat really not been booked?

Or was there an error in the booking where a booking has been made but
the booker's name errored out to NULL?


Would it not be better to have the special person's name "NoOne" and
then ensure that there is noone in the world whom out of perniciousness
against IT have called themselves "NoOne"?

Cheers,
Martin

-- 
----------------
Martin Lomas
martin at ml1.co.uk
----------------



More information about the Nottingham mailing list