Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2006
    Posts
    1

    Data type for "Yes/No/Unknown/NA" Column

    Hi all,

    Say I have a column named "Answer" in a table. This answer will always mean "Yes", "No", "N/A", or "Unknown."

    Should I make this column a tinyint and map 0 to No, 1 to Yes, etc...

    Or should I make this a varchar column and just store the actual answer in the row? Does anyone have suggestions?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the benefit of using tinyint is that it saves space, but it also means that you need to use a join to a lookup table in order to display the meanings

    neither the saved space nor the extra join processing will be measurable unless you're talking about millions of rows

    another thing you want to do is enforce relational integrity, so that you cannot enter a value that isn't one of the accepted values -- but you could do this both with the tinyint or with the actual answer varchars

    basically it's a wash, as far as i can see, so pick the scheme you like the best

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •