Data type for Gender

  • There is some confusion possible with the ambiguous word 'unknown'

    True, Codd's rule 3 says "Null must always be interpreted as an unknown value"  but 'unknown' is plainly used in the sense of an unitialized value i.e. no data was entered.

    'Unknown' in the above example can be a very real value in the sense that it explicitly tells us that the information is not available or cannot be determined; not the same thing at all. This kind of differentiation is very important in many real world data sets.

    [oops rule 3 not 4]

    ...

    -- FORTRAN manual for Xerox Computers --

  • That brings up a very interesting point. When would I use nvarchar vs. varchar?

  • When you need to keep foreign dialects like chinese in the db. You need to use unicode for this task (N). Note that these datatypes take double the space of non unicode types.

  • With the storage being so cheap right now, does it really matter? Unless it is a performance issue. I would consider using a varchar if I had to develop a database where network traffic would be high.

  • If you really want to optimize it for performance, make it a tinyint.  Create a lookup table with all the appropriate values in it and use that.  Numerics are always faster than text.

    As to null and unknown, I'll stick with Codd's definition of it.  Why bother defining something that is already defined?

  • Char vs varchar - There is more to it than just the extra 4 bytes of overhead for each varchar, fixed-length fields can be handled more efficiently than variable-length.  Especially in indexes.

    If you insist on confusing the use of "U" to indicate a known unknown with the uninitialized unknown NULL, then someone has to try coming up with a more precise definition.

  • My two pence:

    I would define "NULL" as a never handled value.

    "UNKNOWN" is a value to me, not something i missed, but something i quote as "UNKNOWN". And i really need to make the difference with "NULL" that means i never computed, evaluate or tell anything about it.

    Again from a pure SQL syntax i would prefer write a single  request :

    "...WHERE something = '"+myvalue+"'..."

    myvalue can here take the "unknown" value

    NULL check needs a different syntax

    "... WHERE something IS NULL..."

     

     

  • NULL is an unknown value.

    But, entering UNKNOWN into a column as a value says that you have evaluated the input and there is enough information (or not) to define it as UNKNOWN.

    And, yes they are 2 different things.  I just normally do not burden my users with UNKNOWN as a selection since I can use NULL to do what they want to do with UNKNOWN.

  • Next question.  Is bald a hair color?


    Cheers,

    david russell

  • Only if you are....:-)

Viewing 10 posts - 16 through 24 (of 24 total)

You must be logged in to reply to this topic. Login to reply