|
Posted by Hugo Kornelis on 10/02/70 11:47
On 11 May 2006 10:20:06 -0700, --CELKO-- wrote:
>Please post DDL, so that people do not have to guess what the keys,
>constraints, Declarative Referential Integrity, data types, etc. in
>your schema are.
>
>CREATE TABLE Colors
>(color_nbr INTEGER NOT NULL PRIMARY KEY,
> color_name CHAR(10) NOT NULL);
>
>CREATE TABLE Weekdays
>(zeller_nbr INTEGER NOT NULL PRIMARY KEY,
> weekday_name CHAR(10) NOT NULL);
Hi Joe,
Are you seriously trying to teel me that after spending months
researching the data, this is your schema?
Both color names and weekday names can vary in length. Clearly, char is
a bad choice of datatype for those columns - use varchar (or character
varying, if you prefer ANSI-speak).
The longest English weekday name is wednesday, which has 9 characters.
Do you really want to end with a day like "wednessday" in your table?
Because if you allow 10 characters, you will!
Colornames can far exceed the lousy 10 characters you allow. Just take a
look on Wikipedia: http://en.wikipedia.org/wiki/List_of_colors. For
instance "International Klein Blue" has 24 characters. I didn't count
the length of all names on that page, nor will I assume that it's a
complete list. I'd allow at least 30 characters. Maybe even 50. (Oh
wait, I'll change it to 49 or 51 to prevent people thinking I'm using
the Access defaults...)
Oh, and please stop using silly column names such as zeller_nbr. We
don't design database schemas to show off how many algorithm names we
remember, we should strive for maintainability. Anything wrong with
weekday_nbr?
>teacher: "Mary, what is 6 times 7?"
>student: "Red?"
>teacher: "Billy, what is 6 times 7?"
>student: "Thursday!"
>teacher: "Johnny, what is 6 times 7?"
>student: "42!"
>teacher: "Johnny, tell the class how you go that answer."
>student: "I divided Red by Thursday!"
You're obviously wrong (again). Johnny built a supercomputer and let it
to calculate for a few billion years.
--
Hugo Kornelis, SQL Server MVP
Navigation:
[Reply to this message]
|