# Re: BOOLEAN RELATIONSHIPS: HARD QUESTION

From: Brian Inglis <Brian.Inglis_at_SystematicSw.Invalid>
Date: Tue, 15 Jun 2004 19:34:30 GMT
Message-ID: <8miuc09hdvqgr8le4j90h8fn40sjco7l3a_at_4ax.com>

On Tue, 15 Jun 2004 10:36:09 +0300 in comp.databases.theory, "x" <x-false_at_yahoo.com> wrote:

>"Jacopo" <jacopols_at_libero.it> wrote in message
>news:bLnzc.110599\$Qc.4194951_at_twister1.libero.it...
>> Thank you very much for your help. Maybe the one you gave me is not the
>> definitive solution since I haven't been able to explain you everything
>but
>> the idea is great and made me think.
>> Let me ask you if I correctly understood what you said:
>> I can create a table with all the possible combination of A, B, and C, an
>> identifier of the combination and a flag to tell if it is allowed or not.

As mentioned below, don't store the disallowed combinations.

>> In the second table a field with the ABC combination identifier and the
>> possible D items associated with it.
>> I need to think about it but it looks good.
>> My only worry at the moment: 25 items in A, 10 in B, 10 in C means
>> 25*10*10=2500 record.

As I suggested for setup, use a spreadsheet and there you can set up all the allowed and disallowed combinations: from these numbers your problem really appears to be a combinatorial problem, and not a boolean or hierarchical relationship, where each B appears only with one A, and each C with one B.

>Wel, you could try to store only the allowed combinations.
>Or the forbidden ones.

I strongly recommend the former, to allow you to present allowed options B for selected A, and C for selected A, B. Read the second part of what I posted, for how to use the data, and store selected combinations and selected D options.

>But I strongly suggest you think more about what cause the forbidden
>combinations.
>
>> I simplified in my explanation but the machine we build are really complex
>> and so I guess in the end the entries in the frist table could be
>millions.
>
>Are you sure your model of the machine is adequate for solving this problem
>?
>Maybe you missed something. Only you can know.

You have to define the allowed combinations somehow and where, and someone (else) has to check whether the data you have created is correct.
If you can find patterns or commonalities in what are allowed or disallowed combinations, you may be able to write code to fill in the allowed entries.
Or you might be able to augment the tables defining all of the A, B, C, D options with additional data that would allow you to write a query to insert allowed combinations, and allowed D options for each combination, into their respective tables.

```--
Thanks. Take care, Brian Inglis 	Calgary, Alberta, Canada

Brian.Inglis_at_CSi.com 	(Brian dot Inglis at SystematicSw dot ab dot ca)