How to apply 3-digit logic to SQL queries?

I deal with past paper issues and continue to run into these questions that concern 3-digit logic. My notes mention this, but do not give examples that relate to those that were asked in the exams.

I understand that True = 1, False = 0and Unknown = 1/2, and also And = Min, Or = Maxand Not(x) = 1-x. However, I do not know how to apply it to such questions as below:

In SQL, discuss the possible truth values ​​of the following expression:
Ra> Rb OR Ra <= 0 OR Rb> = 0
Justify your answer.

and

Owner table phone and age fields can have zero values ​​in them. Given all possible combinations, show which of the three truth values ​​can be returned by the expression:
 phone = 141-3304913 OR age <50 OR age> = 50

Any clarification help for me would be really appreciated :)

+3
source share
1 answer

I will focus on a concrete example that is more suitable for clarifying things. Simply put, your logical expression consists of three parts:

C1: phone = '141-3304913'
C2: age < 50
C3: age >= 50

for which tribule logic states that the result

True, if any clause is true
False, if all clauses are false
Unknown, in all the other cases

, , True, , False , Unknown - , MAX . , MIN. , 0 1 () ; , 1/2, "", .

, () phone P age A:

P1 such that P1 = '141-3304913'
P2 such that P2 <> '141-3304913'
P3 such that P3 = NULL
A1 such that A1 < 50
A2 such that A2 >= 50
A3 such that A3 = NULL

P1 -> C1 = 1
P2 -> C1 = 0
P3 -> C1 = 1/2
A1 -> C2 = 1, C3 = 0
A2 -> C2 = 0, C3 = 1
A3 -> C2 = C3 = 1/2

3 * 3 , :

P1 A1: C1 = 1, C2 = 1, C3 = 0 -> MAX(1,1,0) = 1 -> true
P1 A2: C1 = 1, C2 = 0, C3 = 1 -> MAX(1,0,1) = 1 -> true
P1 A3: C1 = 1, C2 = 1/2, C3 = 1/2 -> MAX(1,1/2,1/2) = 1 -> true
P2 A1: C1 = 0, C2 = 1, C3 = 0 -> MAX(0,1,0) = 1 -> true
P2 A2: C1 = 0, C2 = 0, C3 = 1 -> MAX(0,0,1) = 1 -> true
P2 A3: C1 = 0, C2 = 1/2, C3 = 1/2 -> MAX(0,1/2,1/2) = 1/2 -> unknown
P3 A1: C1 = 1/2, C2 = 1, C3 = 0 -> MAX(1/2,1,0) = 1 -> true
P3 A2: C1 = 1/2, C2 = 0, C3 = 1 -> MAX(1/2,0,1) = 1 -> true
P3 A3: C1 = 1/2, C2 = 1/2, C3 = 1/2 -> MAX(1/2,1/2,1/2) = 1/2 -> unknown

, C2 C3 , False .

R.a > R.b OR R.a <= 0 OR R.b >= 0 :

R.a <= 0, R.a > 0, R.a = unknown
R.b >= 0, R.b < 0, R.b = unknown
R.a - R.b > 0, R.a - R.b <= 0, R.a - R.b = unknown

-, 27 , , R.a - R.b, .

+3

All Articles