Presentation is loading. Please wait.

Presentation is loading. Please wait.

Why Three-Valued Logic is a Mistake ~by 丁碩賢 (689530012) 2001/10/17.

Similar presentations


Presentation on theme: "Why Three-Valued Logic is a Mistake ~by 丁碩賢 (689530012) 2001/10/17."— Presentation transcript:

1 Why Three-Valued Logic is a Mistake ~by 丁碩賢 (689530012) 2001/10/17

2 3VL ’ s Background Nulls A=B, A>B, A<B if A is null or B is null or both (comparison operator) AND, OR, NOT (logical operators) And TUF OR TUF NOT TTUFTTTTTF UUUFUTUUUU FFFFFTUFFT

3 Wrong Answers of the First Kind SELECT E# FROM EMP WHERE JOB = ‘ Clerk ’ OR NOT JOB = ‘ Clerk ’ ; In real world, it ’ s correct. In 3VL, it ’ s incorrect.  OR JOB IS NULL

4 Wrong Answers of the First Kind(Cont.)(Cont.) DEPT.D# = EMP.D# AND EMP.D# = ‘ D1 ’ SELECT E# FROM DEPT, EMP WHERE NOT ( DEPT.D# = EMP.D# AND EMP.D# = ‘D1’ ) DEPTD#EMPE#D# D2E1-- d If d = D1, it evaluates to F If d≠D1, it evaluates to F

5 Wrong Answers of the Second Kind Other examples of expressions that are identically true in 2VL but not in 3VL x=x x>y AND y>z implies x>z T JOIN T = T If T and U have the same heading, then T INTERSECT U = T JOIN U

6 What is the Solution ? We do what we do in the real world ! We use default values. There is no such thing as a null in the real world !

7 A Puzzle Given the foregoing database (and assuming that EMP.D# is a foreign key matching DEPT.D#), show the 3VL and real-world answers to the following pseudoSQL query :the foregoing database SELECT E# FROM EMP WHERE MAYBE ( D# = ‘D1 ) ; (MAYBE is defined to return true if its operand evaluates to unknown, false if its operand evaluates to true or false. )

8 The Key to the Riddle The 3VL answer is E1 The real-world answer is no employee numbers at all  EMP.D# is a foreign key  employee E1 ’ s department number cannot possibly be D1 because no such DEPT exists  So the expression in the WHERE clause must evaluate to false in the real world.

9 Technical Correspondence Leonard Gallagher ’ s disagreement SELECT E# FROM EMP WHERE MAYBE ( D# = ‘D1 ) ; SELECT E# FROM EMP WHERE D# = ‘D1’ IS NOT FALSE ;

10 Technical Correspondence(Cont.) 1. The more columns that can be null, the more complicated the interpretation becomes. 2. Whether or not two nulls are duplicated of one another. 3. It does not invalidate the overall idea of using default values.

11 Technical Correspondence(Cont.) 4. Default values are exactly what we use all the time in the real world. 5. Distinct alternatives for negation 6. NOT TRUE & NOT (TRUE)

12 Technical Correspondence(Cont.) 7. The null meant that the department number exists but is unknown. 8. Obfuscated 3VL and Maxim

13 THE END


Download ppt "Why Three-Valued Logic is a Mistake ~by 丁碩賢 (689530012) 2001/10/17."

Similar presentations


Ads by Google