Mixed, or conditional, datatypes
Date: Sun, 25 Mar 2007 09:14:44 -0400
Example: suppose I'm storing responses to a diagnostic interview. One of the questions asked of the subject is something like
7. Have you always lived in the US?
7a. If the answer to 7 is "no," how many years have you lived in the US?
What I'm wondering is, what's a good way to code this in a relational database?
If I use one field, I could code as an integer, with -1 reserved if the answer to 7 is "yes", but that seems kludgey.
I could use two fields, the first a boolean for 7, and the second an integer for 7a, but then the table is in some sense redundant: the fields are connected by the logic "if 7 is true, then 7a is NULL (or has no meaning even if assigned)". That doesn't seem all that clean either.
TIA Received on Sun Mar 25 2007 - 15:14:44 CEST