Re: Mixed, or conditional, datatypes

From: Chris Edwards <cme_at_ihug.co.nz>
Date: Mon, 26 Mar 2007 23:20:05 +1200
Message-ID: <eu8a5p$ggs$1_at_lust.ihug.co.nz>


On 03/26/07 07:42, JOG wrote:
> On Mar 25, 2:23 pm, Bob Badour <bbad..._at_pei.sympatico.ca> wrote:

>> sinister wrote:
>>> 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?
[...]
>> The truth of the matter is you really have two surveys; even though,
>> someone presented the surveys to respondents as a union of all the
>> questions. Lifelong residents answer one survey and part time residents
>> answer another.
>>
>>  From the above observations, the design seems obvious: Use two relations.

>
> Just to echo this, without a shadow of a doubt more than one relation
> is required, because you are attemptiing to record more than one type
> of proposition - and the RM is based on collectivizing sets of
> propositions of the same type. A "person_details" relation and a
> "years_in_US" relation hence seems intuitive, with the latter
> containing an appropriate foreign key to the former, and a simple JOIN
> being utilized in queries if and when appropriate.

Of course! Why did nobody use examples like this in the courses I studied? I know that Date, for example, takes pains to emphasise that that is precisely what relations are (sets of uniform propositions), but it seems to be all too easily overlooked.

So would the join operation in this case would be an outer join? Since this would result in a relation with a lot of nulls in the non-applicable responses, would it be so bad to store the nulls in the base relation?

I suppose another approach would be to store the response as a single attribute of a domain that supports the values "lifelong resident" (and perhaps "never lived in the US") in addition to numbers for indicating the length of time since moving there. Of course, realistically, you'd probably just record the date the respondent started living in the US (which could be their date of birth, for a lifelong resident).

BTW, is it a coincidence that the "variant record" construct in C is called "union"?

--
Chris
Received on Mon Mar 26 2007 - 13:20:05 CEST

Original text of this message