Databasen - Revisited

Nigel Rantor wiggly at wiggly.org
Thu Oct 19 10:20:39 BST 2006


Matt Sergeant wrote:
> 
> Q: What is wrong with the following setup:
> 
> CREATE TABLE Month (
>   id INTEGER PRIMARY KEY,
>   name VARCHAR(16),
>   shortname VARCHAR(3)
> );
> 
> INSERT INTO Month VALUES (1, "January", "Jan");
> ...
> 
> There are lots of fairly obvious right answers (localisation would be 
> one obvious one), but most people won't get the fact that the primary 
> key index is a bad thing, because the entire table fits into a single 
> page of pretty much every DB I know, so index access is actually slower 
> than a full table scan.
> 
> If they answer with that, it's an instant hire (though I've never given 
> this question to anyone. 9 out of 10 DBAs wouldn't even get it, sadly).

Any decent database's query planner won't use the index in that case 
though, so I don't think it's an 'instant hire' answer.

I take your point about internationalisation but then, I wouldn't hold 
those textual names in the database anyway, my application code is where 
the i8ln should be occuring.

   n


More information about the london.pm mailing list