Вопрос

Prove or disprove:

Given that T=R÷S, it is implied that S=R÷T.


My attempt:

Let us take some R,S tables and we will divide R÷S:

step 1:

     R                           S              ==>       T=R÷S
     -------------            ---------                 -----
    | A | B | C |             | A | B |                  | C |
    | 1 | 2 | 4 |             | 1 | 2 |                  | 4 |
    | 3 | 3 | 4 |             | 3 | 3 |                  | 9 |
    | 1 | 7 | 4 |
    | 1 | 2 | 9 |
    | 1 | 2 | 8 |
    | 3 | 3 | 5 |
    | 4 | 1 | 2 |
    | 3 | 3 | 9 | 

step 2: lt's check R÷T:

      R                          T         ==>          S
     -------------            -----                 -------
    | A | B | C |             | C |                | A | B |
    | 1 | 2 | 4 |             | 4 |                | 1 | 2 |
    | 3 | 3 | 4 |             | 9 |                | 3 | 3 |
    | 1 | 7 | 4 |
    | 1 | 2 | 9 |
    | 1 | 2 | 8 |
    | 3 | 3 | 5 |
    | 4 | 1 | 2 |
    | 3 | 3 | 9 | 

therefore the answer is YES (according to my attempt)

Is my attempt correct?

Это было полезно?

Решение

First, your answer is "Yes" but without any proof, only a single example. You have proven nothing about the general case. If I were to mark your answer, you'd get a straight 0 (OK, maybe a 1 because you understand what relational division is and how to perform it) and a note to read up on mathematical proofs.

For the actual question, the answer is: No, it is not correct. Now to prove that, we do only need a single counter-example. Here it is:

 R                        S          ==>    T=R÷S
 ------------         ---------             -----
| A | B | C |         | A | B |             | C |
| 1 | 2 | 4 |         | 1 | 2 |             | 4 |
| 1 | 2 | 9 |                               | 9 |
| 3 | 3 | 4 |
| 3 | 3 | 8 |
| 3 | 3 | 9 | 
| 4 | 1 | 2 |

But:

 R                      T      ==>       R÷T != S
 ------------         -----           ---------
| A | B | C |         | C |           | A | B |
| 1 | 2 | 4 |         | 4 |           | 1 | 2 |
| 1 | 2 | 9 |         | 9 |           | 3 | 3 |         
| 3 | 3 | 4 |
| 3 | 3 | 8 |
| 3 | 3 | 9 | 
| 4 | 1 | 2 |

This is actually similar to integer division (when we discard the remainder). Sometimes it's Yes:

37 / 7 = 5 (the remainder 2 is discarded) and
37 / 5 = 7 (the remainder 2 is discarded)

and sometimes is No:

37 / 10 = 3 (the remainder 7 is discarded) but
37 / 3 = 12 (the remainder 1 is discarded)

and of course 12 != 10, and the single counter-example disproves the general case.


What can be proven is this:

  • If R÷S = T, then S is a (not necessarily strict) subset of R÷T.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с dba.stackexchange
scroll top