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

Slides:



Advertisements
Similar presentations
Using the Set Operators
Advertisements

WHERE Clause Chapter 2. Objectives Limit rows by using a WHERE clause Use the LIKE operator Effect of NULL values Use compound conditions Use the BETWEEN.
SQL: The Query Language Part 2
primary key constraint foreign key constraint
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 SQL: Queries, Programming, Triggers Chapter 5 Modified by Donghui Zhang.
SQL Subqueries Objectives of the Lecture : To consider the general nature of subqueries. To consider simple versus correlated subqueries. To consider the.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A Modified by Donghui Zhang.
CS 405G: Introduction to Database Systems
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Extended SQL & The Relational Calculus.
Data Warehousing/Mining 1 Data Warehousing/Mining Comp 150 Aggregation in SQL (not in book) Instructor: Dan Hebert.
LECTURE 8.  Consider the table employee(employee_id,last_name,job_id, department_id )  assume that you want to display all the employees in department.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 52 Database Systems I Relational Algebra.
Instructor: Craig Duckett CASE, ORDER BY, GROUP BY, HAVING, Subqueries
 CS 405G: Introduction to Database Systems Lecture 7: Relational Algebra II Instructor: Chen Qian Spring 2014.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 2: Single-Table Selections.
True/False. False True Subject May Go Here True / False ? Type correct answer here. Type incorrect answer here.
Determine whether each curve below is the graph of a function of x. Select all answers that are graphs of functions of x:
Rutgers University Relational Algebra 198:541 Rutgers University.
CSCD343- Introduction to databases- A. Vaisman1 Relational Algebra.
Objectives After completing this lesson, you should be able to do the following: Define subqueries Describe the types of problems that the subqueries.
 The WHERE clause, also called the predicate, provides the power to narrow down the scope of the data retrieved.  Comparison Operators Comparison OperatorDefinition.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 3: Introduction.
Advanced SQL Murat Kantarcioglu Adapted from Silberchatz et al. slides.
Test on Topic 16 Radicals Solutions
1 ICS 184: Introduction to Data Management Lecture Note 10 SQL as a Query Language (Cont.)
LECTURE 8.  Consider the table employee(employee_id,last_name,job_id, department_id )  assume that you want to display all the employees in department.
Comparisons Hold up the ‘+’ card if you think the answer is always positive. Hold up the ‘-’ card if you think the answer is always negative. The ?? Card.
Natural vs. Generated Keys. Definitions Natural key—a key that occurs in the data, that uniquely identifies rows. AKA candidate key. Generated key—a key.
SQL (DDL & DML Commands)
DATABASE TRANSACTION. Transaction It is a logical unit of work that must succeed or fail in its entirety. A transaction is an atomic operation which may.
SQL- DQL (Oracle Version). 2 SELECT Statement Syntax SELECT [DISTINCT] column_list FROM table_list [WHERE conditional expression] [GROUP BY column_list]
NULLs & Outer Joins Objectives of the Lecture : To consider the use of NULLs in SQL. To consider Outer Join Operations, and their implementation in SQL.
Join, Subqueries and set operators. Obtaining Data from Multiple Tables EMPLOYEES DEPARTMENTS … …
1 Relational Algebra Chapter 4, Sections 4.1 – 4.2.
INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS Dr. Adam Anthony Fall 2012.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
Copyright © 2004, Oracle. All rights reserved. Lecture 4: 1-Retrieving Data Using the SQL SELECT Statement 2-Restricting and Sorting Data Lecture 4: 1-Retrieving.
I-1 Copyright س Oracle Corporation, All rights reserved. Data Retrieval.
CSCD34-Data Management Systems - A. Vaisman1 Relational Algebra.
NULL VALUES CHAPTER 5 (6/E) CHAPTER 8 (5/E) 1. LECTURE OUTLINE  Dealing with null values Three-valued logic Effects in WHERE clauses IS NULL Effects.
Installment Numbers 6 Answers to Puzzle Corner Problems (Installment Numbers1-5) 會研所 黃潔.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Subqueries These slides are licensed under.
Access Queries Agenda 6/16/14 Review Access Project Part 1, answer questions Discuss queries: Turning data stored in a database into information for decision.
1 CS 430 Database Theory Winter 2005 Lecture 5: Relational Algebra.
INSTALL NUMBER 12 Answers to Puzzle Corner Problems (Installment Number 7-11) 中正大學資管所 碩一 郭 溥 淵.
SqlExam1Review.ppt EXAM - 1. SQL stands for -- Structured Query Language Putting a manual database on a computer ensures? Data is more current Data is.
Negative and Zero Exponents
Copyright س Oracle Corporation, All rights reserved. I Introduction.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Relational State Assertions These slides.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Grouping These slides are licensed under.
CS 405G: Introduction to Database Systems SQL III.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Collection Operators These slides are.
Simple Queries DBS301 – Week 1. Objectives Basic SELECT statement Computed columns Aliases Concatenation operator Use of DISTINCT to eliminate duplicates.
Restricting and Sorting Data
More SQL: Complex Queries,
Writing Basic SQL SELECT Statements
Instructor: Craig Duckett Lecture 09: Tuesday, April 25th, 2017
Using Subqueries to Solve Queries
Aggregating Data Using Group Functions
Writing Correlated Subqueries
Using the Set Operators
More SQL Nested and Union queries, and more
Restricting and Sorting Data
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Using Subqueries to Solve Queries
Database Design: Relational Model
Section 3.7 Switching Circuits
Restricting and Sorting Data
Database Programming Using Oracle 11g
Restricting and Sorting Data
Presentation transcript:

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

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

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

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

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

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 !

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. )

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.

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

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.

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)

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

THE END