If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Data type for "Yes/No/Unknown/NA" Column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-13-06, 21:30
bzburns bzburns is offline
Registered User
 
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?
Reply With Quote
  #2 (permalink)  
Old 09-13-06, 22:19
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On