SQL Semantics V-tables c-tables
Uncertain Data Management NULLs
Antoine Amarilli1, Silviu Maniu2
1Télécom ParisTech
2LRI
November 30th, 2015
SQL Semantics V-tables c-tables
NULLs
Representmissing informationin a relation.
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-07 Antoine UDM NULL 2015-12-14 NULL UDM NULL Other name: Codd tables.
SQL Semantics V-tables c-tables
NULLs
Representmissing informationin a relation.
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-07 Antoine UDM NULL 2015-12-14 NULL UDM NULL
Other name: Codd tables.
SQL Semantics V-tables c-tables
NULLs
Representmissing informationin a relation.
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-07 Antoine UDM NULL 2015-12-14 NULL UDM NULL Other name: Codd tables.
SQL Semantics V-tables c-tables
Semantics
EachNULL can be replacedindependently byanydomain value
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-07 Antoine UDM
2015-12-14 UDM
SQL Semantics V-tables c-tables
Semantics
EachNULL can be replacedindependently byanydomain value Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-07 Antoine UDM NULL 2015-12-14 NULL UDM NULL
SQL Semantics V-tables c-tables
Semantics
EachNULL can be replacedindependently byanydomain value Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-07 Antoine UDM C42 2015-12-14 Silviu UDM C42
SQL Semantics V-tables c-tables
Semantics
EachNULL can be replacedindependently byanydomain value Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-07 Antoine UDM xbecz 2015-12-14 gruiiik UDM buuuk
SQL Semantics V-tables c-tables
Tricky semantics
How can we evaluatequeries on Codd tables?
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-07 Antoine UDM NULL 2015-12-14 NULL UDM NULL SELECT * FROM Book WHERE room='C47';
Book
date teacher class room 2015-11-23 Antoine UDM C47
→ Tricky semantics, oftencriticized!
SQL Semantics V-tables c-tables
Tricky semantics
How can we evaluatequeries on Codd tables?
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-07 Antoine UDM NULL 2015-12-14 NULL UDM NULL SELECT * FROM Book WHERE room='C47';
Book
date teacher class room 2015-11-23 Antoine UDM C47
→ Tricky semantics, oftencriticized!
SQL Semantics V-tables c-tables
Tricky semantics
How can we evaluatequeries on Codd tables?
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-07 Antoine UDM NULL 2015-12-14 NULL UDM NULL SELECT * FROM Book WHERE room='C47';
Book
date teacher class room 2015-11-23 Antoine UDM C47
→ Tricky semantics, oftencriticized!
SQL Semantics V-tables c-tables
Tricky semantics
How can we evaluatequeries on Codd tables?
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-07 Antoine UDM NULL 2015-12-14 NULL UDM NULL SELECT * FROM Book WHERE room='C47';
Book
date teacher class room 2015-11-23 Antoine UDM C47
SQL Semantics V-tables c-tables
Three-valued logic
Usually, we evaluate operations as Boolean:
WHERE a='42' OR (b=c AND NOT (c=d))
→ WHERE False OR (True AND NOT (True))
→ False
In SQL, values can be True,False, or Unknown(NULL) Essentially anythingthat involvesNULL is NULL
SQL Semantics V-tables c-tables
Three-valued logic
Usually, we evaluate operations as Boolean:
WHERE a='42' OR (b=c AND NOT (c=d))
→ WHERE False OR (True AND NOT (True))
→ False
In SQL, values can be True,False, or Unknown(NULL)
Essentially anythingthat involvesNULL is NULL
SQL Semantics V-tables c-tables
Three-valued logic
Usually, we evaluate operations as Boolean:
WHERE a='42' OR (b=c AND NOT (c=d))
→ WHERE False OR (True AND NOT (True))
→ False
In SQL, values can be True,False, or Unknown(NULL) Essentially anythingthat involvesNULL is NULL
SQL Semantics V-tables c-tables
Three-valued logic (example)
WHERE 42=43 OR (42=NULL OR 42=43)
→ False OR (Unknown OR False)
→ False OR Unknown
→ Unknown
WHERE 42=45 OR (42=NULL OR 42=42)
→ False OR (Unknown OR True)
→ False OR True
→ True
SQL Semantics V-tables c-tables
Three-valued logic (example)
WHERE 42=43 OR (42=NULL OR 42=43)
→ False OR (Unknown OR False)
→ False OR Unknown
→ Unknown
WHERE 42=45 OR (42=NULL OR 42=42)
→ False OR (Unknown OR True)
→ False OR True
→ True
SQL Semantics V-tables c-tables
Three-valued logic (example)
WHERE 42=43 OR (42=NULL OR 42=43)
→ False OR (Unknown OR False)
→ False OR Unknown
→ Unknown
WHERE 42=45 OR (42=NULL OR 42=42)
→ False OR (Unknown OR True)
→ False OR True
→ True
SQL Semantics V-tables c-tables
Three-valued logic (example)
WHERE 42=43 OR (42=NULL OR 42=43)
→ False OR (Unknown OR False)
→ False OR Unknown
→ Unknown
WHERE 42=45 OR (42=NULL OR 42=42)
→ False OR (Unknown OR True)
→ False OR True
→ True
SQL Semantics V-tables c-tables
Three-valued logic (example)
WHERE 42=43 OR (42=NULL OR 42=43)
→ False OR (Unknown OR False)
→ False OR Unknown
→ Unknown
WHERE 42=45 OR (42=NULL OR 42=42)
→ False OR (Unknown OR True)
→ False OR True
→ True
SQL Semantics V-tables c-tables
Three-valued logic (example)
WHERE 42=43 OR (42=NULL OR 42=43)
→ False OR (Unknown OR False)
→ False OR Unknown
→ Unknown
WHERE 42=45 OR (42=NULL OR 42=42)
→ False OR (Unknown OR True)
→ False OR True
→ True
SQL Semantics V-tables c-tables
Three-valued logic (example)
WHERE 42=43 OR (42=NULL OR 42=43)
→ False OR (Unknown OR False)
→ False OR Unknown
→ Unknown
WHERE 42=45 OR (42=NULL OR 42=42)
→ False OR (Unknown OR True)
→ False OR True
→ True
SQL Semantics V-tables c-tables
Three-valued logic (example)
WHERE 42=43 OR (42=NULL OR 42=43)
→ False OR (Unknown OR False)
→ False OR Unknown
→ Unknown
WHERE 42=45 OR (42=NULL OR 42=42)
→ False OR (Unknown OR True)
→ False OR True
→ True
SQL Semantics V-tables c-tables
Three-valued logic (AND table)
AND True False
NULL
True True False
NULL
False False False
False NULL NULL False NULL
SQL Semantics V-tables c-tables
Three-valued logic (AND table)
AND True False NULL True True False
NULL
False False False
False
NULL
NULL False NULL
SQL Semantics V-tables c-tables
Three-valued logic (AND table)
AND True False NULL True True False
NULL
False False False False NULL
NULL
False
NULL
SQL Semantics V-tables c-tables
Three-valued logic (AND table)
AND True False NULL True True False NULL False False False False NULL NULL False NULL
SQL Semantics V-tables c-tables
Three-valued logic (OR table)
OR True False
NULL
True True True
True
False True False
NULL NULL True NULL NULL
SQL Semantics V-tables c-tables
Three-valued logic (OR table)
OR True False NULL True True True
True
False True False
NULL
NULL
True NULL NULL
SQL Semantics V-tables c-tables
Three-valued logic (OR table)
OR True False NULL True True True True False True False
NULL
NULL True
NULL NULL
SQL Semantics V-tables c-tables
Three-valued logic (OR table)
OR True False NULL True True True True False True False NULL NULL True NULL NULL
SQL Semantics V-tables c-tables
Three-valued logic (traps)
What is NULL * 42?
→ NULL
What is NULL / 0?
→ Implementation-dependent: NULLor error What is NULL =NULL?
→ NULL
What does the following do?
SELECT * FROM Book WHERE room=NULL
→ Returns anempty result What does the following do?
SELECT * FROM Book WHERE room='C42' OR room<>'C42'
→ Return everything whereroomisnotNULL
SQL Semantics V-tables c-tables
Three-valued logic (traps)
What is NULL * 42?
→ NULL
What is NULL / 0?
→ Implementation-dependent: NULLor error What is NULL =NULL?
→ NULL
What does the following do?
SELECT * FROM Book WHERE room=NULL
→ Returns anempty result What does the following do?
SELECT * FROM Book WHERE room='C42' OR room<>'C42'
→ Return everything whereroomisnotNULL
SQL Semantics V-tables c-tables
Three-valued logic (traps)
What is NULL * 42?
→ NULL
What is NULL / 0?
→ Implementation-dependent: NULLor error What is NULL =NULL?
→ NULL
What does the following do?
SELECT * FROM Book WHERE room=NULL
→ Returns anempty result What does the following do?
SELECT * FROM Book WHERE room='C42' OR room<>'C42'
→ Return everything whereroomisnotNULL
SQL Semantics V-tables c-tables
Three-valued logic (traps)
What is NULL * 42?
→ NULL
What is NULL / 0?
→ Implementation-dependent: NULLor error
What is NULL =NULL?
→ NULL
What does the following do?
SELECT * FROM Book WHERE room=NULL
→ Returns anempty result What does the following do?
SELECT * FROM Book WHERE room='C42' OR room<>'C42'
→ Return everything whereroomisnotNULL
SQL Semantics V-tables c-tables
Three-valued logic (traps)
What is NULL * 42?
→ NULL
What is NULL / 0?
→ Implementation-dependent: NULLor error What is NULL =NULL?
→ NULL
What does the following do?
SELECT * FROM Book WHERE room=NULL
→ Returns anempty result What does the following do?
SELECT * FROM Book WHERE room='C42' OR room<>'C42'
→ Return everything whereroomisnotNULL
SQL Semantics V-tables c-tables
Three-valued logic (traps)
What is NULL * 42?
→ NULL
What is NULL / 0?
→ Implementation-dependent: NULLor error What is NULL =NULL?
→ NULL
What does the following do?
SELECT * FROM Book WHERE room=NULL
→ Returns anempty result What does the following do?
SELECT * FROM Book WHERE room='C42' OR room<>'C42'
→ Return everything whereroomisnotNULL
SQL Semantics V-tables c-tables
Three-valued logic (traps)
What is NULL * 42?
→ NULL
What is NULL / 0?
→ Implementation-dependent: NULLor error What is NULL =NULL?
→ NULL
What does the following do?
SELECT * FROM Book WHERE room=NULL
→ Returns anempty result What does the following do?
SELECT * FROM Book WHERE room='C42' OR room<>'C42'
→ Return everything whereroomisnotNULL
SQL Semantics V-tables c-tables
Three-valued logic (traps)
What is NULL * 42?
→ NULL
What is NULL / 0?
→ Implementation-dependent: NULLor error What is NULL =NULL?
→ NULL
What does the following do?
SELECT * FROM Book WHERE room=NULL
→ Returns anempty result
What does the following do?
SELECT * FROM Book WHERE room='C42' OR room<>'C42'
→ Return everything whereroomisnotNULL
SQL Semantics V-tables c-tables
Three-valued logic (traps)
What is NULL * 42?
→ NULL
What is NULL / 0?
→ Implementation-dependent: NULLor error What is NULL =NULL?
→ NULL
What does the following do?
SELECT * FROM Book WHERE room=NULL
→ Returns anempty result What does the following do?
SELECT * FROM Book WHERE room='C42' OR room<>'C42'
→ Return everything whereroomisnotNULL
SQL Semantics V-tables c-tables
Three-valued logic (traps)
What is NULL * 42?
→ NULL
What is NULL / 0?
→ Implementation-dependent: NULLor error What is NULL =NULL?
→ NULL
What does the following do?
SELECT * FROM Book WHERE room=NULL
→ Returns anempty result What does the following do?
SELECT * FROM Book WHERE room='C42' OR room<>'C42'
→ Return everything where isnot
SQL Semantics V-tables c-tables
Three-valued logic (fixes)
IS NULL
→ test if an expression isNULL Law of excluded fourth:
[COND] IS TRUE OR [COND] IS FALSE OR [COND] IS NULL
SQL Semantics V-tables c-tables
Three-valued logic (more complaints)
This issillyin terms of semantics!
Book
date teacher class room 2015-12-07 Antoine UDM NULL
SELECT * FROM Book WHERE room='C42' OR room<>'C42'
Possible worlds:
Either theNULL is'C42' ... or theNULL is something else
→ ... so the tuple should match in either case!
SQL Semantics V-tables c-tables
Three-valued logic (more complaints)
This issillyin terms of semantics!
Book
date teacher class room 2015-12-07 Antoine UDM NULL
SELECT * FROM Book WHERE room='C42' OR room<>'C42' Possible worlds:
Either theNULL is'C42' ... or theNULL is something else
→ ... so the tuple should match in either case!
SQL Semantics V-tables c-tables
Three-valued logic (more complaints)
This issillyin terms of semantics!
Book
date teacher class room 2015-12-07 Antoine UDM NULL
SELECT * FROM Book WHERE room='C42' OR room<>'C42' Possible worlds:
Either theNULL is'C42' ... or theNULL is something else
→ ... so the tuple should match in either case!
SQL Semantics V-tables c-tables
Three-valued logic (more traps!)
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-03 Antoine UDM NULL
Repairs room cause C42 lavatory leak NULL leopard
SELECT * FROM Book WHERE room NOT IN (SELECT room FROM Repairs)
→ Empty result!
SELECT * FROM Book WHERE room NOT IN
(SELECT room FROM Repairs WHERE room IS NOT NULL)
→ Does notcontain theNULL for 2015-12-03 SELECT * FROM Book WHERE
(room IN (SELECT room FROM Repairs) IS NOT TRUE)
SQL Semantics V-tables c-tables
Three-valued logic (more traps!)
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-03 Antoine UDM NULL
Repairs room cause C42 lavatory leak NULL leopard
SELECT * FROM Book WHERE room NOT IN (SELECT room FROM Repairs)
→ Empty result!
SELECT * FROM Book WHERE room NOT IN
(SELECT room FROM Repairs WHERE room IS NOT NULL)
→ Does notcontain theNULL for 2015-12-03 SELECT * FROM Book WHERE
(room IN (SELECT room FROM Repairs) IS NOT TRUE)
SQL Semantics V-tables c-tables
Three-valued logic (more traps!)
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-03 Antoine UDM NULL
Repairs room cause C42 lavatory leak NULL leopard
SELECT * FROM Book WHERE room NOT IN (SELECT room FROM Repairs)
→ Empty result!
SELECT * FROM Book WHERE room NOT IN
(SELECT room FROM Repairs WHERE room IS NOT NULL)
→ Does notcontain theNULL for 2015-12-03 SELECT * FROM Book WHERE
(room IN (SELECT room FROM Repairs) IS NOT TRUE)
SQL Semantics V-tables c-tables
Three-valued logic (more traps!)
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-03 Antoine UDM NULL
Repairs room cause C42 lavatory leak NULL leopard
SELECT * FROM Book WHERE room NOT IN (SELECT room FROM Repairs)
→ Empty result!
SELECT * FROM Book WHERE room NOT IN
(SELECT room FROM Repairs WHERE room IS NOT NULL)
→ Does notcontain theNULL for 2015-12-03 SELECT * FROM Book WHERE
(room IN (SELECT room FROM Repairs) IS NOT TRUE)
SQL Semantics V-tables c-tables
Three-valued logic (more traps!)
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-03 Antoine UDM NULL
Repairs room cause C42 lavatory leak NULL leopard
SELECT * FROM Book WHERE room NOT IN (SELECT room FROM Repairs)
→ Empty result!
SELECT * FROM Book WHERE room NOT IN
(SELECT room FROM Repairs WHERE room IS NOT NULL)
→ Does notcontain theNULL for 2015-12-03 SELECT * FROM Book WHERE
(room IN (SELECT room FROM Repairs) IS NOT TRUE)
SQL Semantics V-tables c-tables
Three-valued logic (more traps!)
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-03 Antoine UDM NULL
Repairs room cause C42 lavatory leak NULL leopard
SELECT * FROM Book WHERE room NOT IN (SELECT room FROM Repairs)
→ Empty result!
SELECT * FROM Book WHERE room NOT IN
(SELECT room FROM Repairs WHERE room IS NOT NULL)
→ Does notcontain theNULL for 2015-12-03
SELECT * FROM Book WHERE
(room IN (SELECT room FROM Repairs) IS NOT TRUE)
SQL Semantics V-tables c-tables
Three-valued logic (more traps!)
Book
date teacher class room 2015-11-23 Antoine UDM C47 2015-11-30 Antoine UDM C017 2015-12-03 Antoine UDM NULL
Repairs room cause C42 lavatory leak NULL leopard
SELECT * FROM Book WHERE room NOT IN (SELECT room FROM Repairs)
→ Empty result!
SELECT * FROM Book WHERE room NOT IN
(SELECT room FROM Repairs WHERE room IS NOT NULL)
→ Does notcontain theNULL for 2015-12-03
SQL Semantics V-tables c-tables
Even more traps with NULLs
SELECT * FROM R NATURAL JOIN S
→ NULLs willneverjoin
SELECT a FROM R UNION SELECT a FROM S
→ multiple NULLs willnotbe kept SELECT DISTINCT a FROM R
→ multiple NULLs willnotbe kept
SQL Semantics V-tables c-tables
Even more traps with NULLs
SELECT * FROM R NATURAL JOIN S
→ NULLs willneverjoin
SELECT a FROM R UNION SELECT a FROM S
→ multiple NULLs willnotbe kept SELECT DISTINCT a FROM R
→ multiple NULLs willnotbe kept
SQL Semantics V-tables c-tables
Even more traps with NULLs
SELECT * FROM R NATURAL JOIN S
→ NULLs willneverjoin
SELECT a FROM R UNION SELECT a FROM S
→ multiple NULLs willnotbe kept SELECT DISTINCT a FROM R
→ multiple NULLs willnotbe kept
SQL Semantics V-tables c-tables
Even more traps with NULLs
SELECT * FROM R NATURAL JOIN S
→ NULLs willneverjoin
SELECT a FROM R UNION SELECT a FROM S
→ multiple NULLs willnotbe kept
SELECT DISTINCT a FROM R
→ multiple NULLs willnotbe kept
SQL Semantics V-tables c-tables
Even more traps with NULLs
SELECT * FROM R NATURAL JOIN S
→ NULLs willneverjoin
SELECT a FROM R UNION SELECT a FROM S
→ multiple NULLs willnotbe kept SELECT DISTINCT a FROM R
→ multiple NULLs willnotbe kept
SQL Semantics V-tables c-tables
Even more traps with NULLs
SELECT * FROM R NATURAL JOIN S
→ NULLs willneverjoin
SELECT a FROM R UNION SELECT a FROM S
→ multiple NULLs willnotbe kept SELECT DISTINCT a FROM R
→ multiple NULLs willnotbe kept
SQL Semantics V-tables c-tables
Even, even more traps about NULLs
SELECT COUNT(*) FROM R
→ NULLswill be counted SELECT COUNT(a) FROM R
→ NULLswill beignored! SELECT SUM(a) FROM R
→ NULLs will beignored
SELECT AVG(a),SUM(a)/COUNT(*) FROM R
→ values maydiffer
SQL Semantics V-tables c-tables
Even, even more traps about NULLs
SELECT COUNT(*) FROM R
→ NULLswill be counted SELECT COUNT(a) FROM R
→ NULLswill beignored! SELECT SUM(a) FROM R
→ NULLs will beignored
SELECT AVG(a),SUM(a)/COUNT(*) FROM R
→ values maydiffer
SQL Semantics V-tables c-tables
Even, even more traps about NULLs
SELECT COUNT(*) FROM R
→ NULLswill be counted
SELECT COUNT(a) FROM R
→ NULLswill beignored! SELECT SUM(a) FROM R
→ NULLs will beignored
SELECT AVG(a),SUM(a)/COUNT(*) FROM R
→ values maydiffer
SQL Semantics V-tables c-tables
Even, even more traps about NULLs
SELECT COUNT(*) FROM R
→ NULLswill be counted SELECT COUNT(a) FROM R
→ NULLswill beignored! SELECT SUM(a) FROM R
→ NULLs will beignored
SELECT AVG(a),SUM(a)/COUNT(*) FROM R
→ values maydiffer
SQL Semantics V-tables c-tables
Even, even more traps about NULLs
SELECT COUNT(*) FROM R
→ NULLswill be counted SELECT COUNT(a) FROM R
→ NULLswill beignored!
SELECT SUM(a) FROM R
→ NULLs will beignored
SELECT AVG(a),SUM(a)/COUNT(*) FROM R
→ values maydiffer
SQL Semantics V-tables c-tables
Even, even more traps about NULLs
SELECT COUNT(*) FROM R
→ NULLswill be counted SELECT COUNT(a) FROM R
→ NULLswill beignored!
SELECT SUM(a) FROM R
→ NULLs will beignored
SELECT AVG(a),SUM(a)/COUNT(*) FROM R
→ values maydiffer
SQL Semantics V-tables c-tables
Even, even more traps about NULLs
SELECT COUNT(*) FROM R
→ NULLswill be counted SELECT COUNT(a) FROM R
→ NULLswill beignored!
SELECT SUM(a) FROM R
→ NULLs will beignored
SELECT AVG(a),SUM(a)/COUNT(*) FROM R
→ values maydiffer
SQL Semantics V-tables c-tables
Even, even more traps about NULLs
SELECT COUNT(*) FROM R
→ NULLswill be counted SELECT COUNT(a) FROM R
→ NULLswill beignored!
SELECT SUM(a) FROM R
→ NULLs will beignored
SELECT AVG(a),SUM(a)/COUNT(*) FROM R
→ values maydiffer
SQL Semantics V-tables c-tables
Even, even more traps about NULLs
SELECT COUNT(*) FROM R
→ NULLswill be counted SELECT COUNT(a) FROM R
→ NULLswill beignored!
SELECT SUM(a) FROM R
→ NULLs will beignored
SELECT AVG(a),SUM(a)/COUNT(*) FROM R
→ values maydiffer
SQL Semantics V-tables c-tables
Table of contents
1 SQL
2 Semantics
3 V-tables
4 c-tables
SQL Semantics V-tables c-tables
Semantics
We fix a signatureσ:
→ relationnames
→ associatedarity
We define uncertain interpretationsfor each relation
SQL Semantics V-tables c-tables
Uncertain relation
An uncertain relation: set ofpossible worlds
Booking date tch room
23 A. a
Booking date tch room
23 A. b
Booking date tch room
23 A. c
· · ·
SQL Semantics V-tables c-tables
Uncertain relation
An uncertain relation: set ofpossible worlds
Booking date tch room
23 A. a
Booking date tch room
23 A. b
Booking date tch room
23 A. c
· · ·
SQL Semantics V-tables c-tables
Relational algebra
Extend relational algebra operators to uncertain relations The possible worldsof the result should be...
take allpossible worldsof the inputs
apply the operation and get apossible output
Booking 23 A. a
Booking 23 A. b
Booking 23 A. c
...
∪
Booking 30 a C017
Booking 30 b C017
Booking 30 c C017
...
=
Booking 23 A. a 30 b C017
Booking 23 A. b 30 a C017
...
SQL Semantics V-tables c-tables
Relational algebra
Extend relational algebra operators to uncertain relations The possible worldsof the result should be...
take allpossible worldsof the inputs
apply the operation and get apossible output
Booking 23 A. a
Booking 23 A. b
Booking 23 A. c
∪
Booking 30 a C017
Booking 30 b C017
Booking 30 c C017
...
=
Booking 23 A. a 30 b C017
Booking 23 A. b 30 a C017
...
SQL Semantics V-tables c-tables
Relational algebra
Extend relational algebra operators to uncertain relations The possible worldsof the result should be...
take allpossible worldsof the inputs
apply the operation and get apossible output
Booking 23 A. a
Booking 23 A. b
Booking 23 A. c
∪
Booking 30 a C017
Booking 30 b C017
Booking 30 c C017
...
=
Booking 23 A. a 30 b C017
Booking 23 A. b 30 a C017
...
SQL Semantics V-tables c-tables
Relational algebra
Extend relational algebra operators to uncertain relations The possible worldsof the result should be...
take allpossible worldsof the inputs
apply the operation and get apossible output
Booking 23 A. a
Booking 23 A. b
Booking 23 A. c
∪
Booking 30 a C017
Booking 30 b C017
Booking 30 c C017
=
Booking 23 A. a 30 b C017
Booking 23 A. b 30 a C017
...
SQL Semantics V-tables c-tables
Relational algebra
Extend relational algebra operators to uncertain relations The possible worldsof the result should be...
take allpossible worldsof the inputs
apply the operation and get apossible output
Booking 23 A. a
Booking 23 A. b
Booking 23 A. c
∪
Booking 30 a C017
Booking 30 b C017
Booking 30 c C017
=
Booking 23 A. a 30 b C017
Booking 23 A. b 30 a C017
...
SQL Semantics V-tables c-tables
Relational algebra
Extend relational algebra operators to uncertain relations The possible worldsof the result should be...
take allpossible worldsof the inputs
apply the operation and get apossible output
Booking 23 A. a
Booking 23 A. b
Booking 23 A. c
∪
Booking 30 a C017
Booking 30 b C017
Booking 30 c C017
=
Booking 23 A. a 30 b C017
Booking 23 A. b 30 a C017
..
SQL Semantics V-tables c-tables
Representation system
Tables withNULL are arepresentation of uncertain tables
Booking
23 A. NULL stands for
Booking 23 A. a
Booking 23 A. b
Booking 23 A. c
...
SQL Semantics V-tables c-tables
Representation system
Tables withNULL are arepresentation of uncertain tables
Booking 23 A. NULL
stands for
Booking 23 A. a
Booking 23 A. b
Booking 23 A. c
...
SQL Semantics V-tables c-tables
Representation system
Tables withNULL are arepresentation of uncertain tables
Booking
23 A. NULL stands for
Booking 23 A. a
Booking 23 A. b
Booking 23 A. c
...
SQL Semantics V-tables c-tables
Representation system
Tables withNULL are arepresentation of uncertain tables
Booking
23 A. NULL stands for
Booking 23 A. a
Booking 23 A. b
Booking 23 A. c
...
SQL Semantics V-tables c-tables
Back to the silly example
Book
date teacher class room 2015-12-07 Antoine UDM NULL 2015-12-14 Silviu UDM C47 SELECT * FROM Book WHERE teacher='Antoine' AND
(room='C42' OR room<>'C42')
→ How to representthe result?
SQL Semantics V-tables c-tables
Back to the silly example
Book
date teacher class room 2015-12-07 Antoine UDM NULL 2015-12-14 Silviu UDM C47 SELECT * FROM Book WHERE teacher='Antoine' AND
(room='C42' OR room<>'C42')
→ How to representthe result?
SQL Semantics V-tables c-tables
Representing the output
07 A. UDM NULL 14 S. UDM C47
represents 07 A. UDM a
14 S. UDM C47
07 A. UDM b 14 S. UDM C47
07 A. UDM C42 14 S. UDM C47 · · · SELECT * FROM Book WHERE teacher='A.' AND
(room='C42' OR room<>'C42')
07 A. UDM a 07 A. UDM b 07 A. UDM C42 · · · represented as
07 A. UDM NULL
SQL Semantics V-tables c-tables
Representing the output
07 A. UDM NULL 14 S. UDM C47
represents
07 A. UDM a 14 S. UDM C47
07 A. UDM b 14 S. UDM C47
07 A. UDM C42 14 S. UDM C47 · · · SELECT * FROM Book WHERE teacher='A.' AND
(room='C42' OR room<>'C42')
07 A. UDM a 07 A. UDM b 07 A. UDM C42 · · · represented as
07 A. UDM NULL
SQL Semantics V-tables c-tables
Representing the output
07 A. UDM NULL 14 S. UDM C47
represents 07 A. UDM a
14 S. UDM C47
07 A. UDM b 14 S. UDM C47
07 A. UDM C42 14 S. UDM C47 · · ·
SELECT * FROM Book WHERE teacher='A.' AND (room='C42' OR room<>'C42')
07 A. UDM a 07 A. UDM b 07 A. UDM C42 · · · represented as
07 A. UDM NULL
SQL Semantics V-tables c-tables
Representing the output
07 A. UDM NULL 14 S. UDM C47
represents 07 A. UDM a
14 S. UDM C47
07 A. UDM b 14 S. UDM C47
07 A. UDM C42 14 S. UDM C47 · · · SELECT * FROM Book WHERE teacher='A.' AND
(room='C42' OR room<>'C42')
07 A. UDM a 07 A. UDM b 07 A. UDM C42 · · · represented as
07 A. UDM NULL
SQL Semantics V-tables c-tables
Representing the output
07 A. UDM NULL 14 S. UDM C47
represents 07 A. UDM a
14 S. UDM C47
07 A. UDM b 14 S. UDM C47
07 A. UDM C42 14 S. UDM C47 · · · SELECT * FROM Book WHERE teacher='A.' AND
(room='C42' OR room<>'C42')
07 A. UDM a 07 A. UDM b 07 A. UDM C42 · · ·
represented as 07 A. UDM NULL
SQL Semantics V-tables c-tables
Representing the output
07 A. UDM NULL 14 S. UDM C47
represents 07 A. UDM a
14 S. UDM C47
07 A. UDM b 14 S. UDM C47
07 A. UDM C42 14 S. UDM C47 · · · SELECT * FROM Book WHERE teacher='A.' AND
(room='C42' OR room<>'C42')
07 A. UDM a 07 A. UDM b 07 A. UDM C42 · · · represented as
07 A. UDM NULL
SQL Semantics V-tables c-tables
Representing the output
07 A. UDM NULL 14 S. UDM C47
represents 07 A. UDM a
14 S. UDM C47
07 A. UDM b 14 S. UDM C47
07 A. UDM C42 14 S. UDM C47 · · · SELECT * FROM Book WHERE teacher='A.' AND
(room='C42' OR room<>'C42')
07 A. UDM a 07 A. UDM b 07 A. UDM C42 · · · represented as
SQL Semantics V-tables c-tables
Representation system definition
Uncertain instance: set of possible worlds
Uncertainty framework: concise way to represent uncertain instances
Here, Codd tables Query language: here, relational algebra
Definition (Strong representation system) For any query in the language,
on uncertain instances represented in the framework, the uncertain instance obtained by evaluating the query can also be represented in the framework.
→ Are Codd tables astrong representation system?
SQL Semantics V-tables c-tables
Representation system definition
Uncertain instance: set of possible worlds Uncertainty framework: concise way to represent
uncertain instances Here, Codd tables
Query language: here, relational algebra
Definition (Strong representation system) For any query in the language,
on uncertain instances represented in the framework, the uncertain instance obtained by evaluating the query can also be represented in the framework.
→ Are Codd tables astrong representation system?
SQL Semantics V-tables c-tables
Representation system definition
Uncertain instance: set of possible worlds Uncertainty framework: concise way to represent
uncertain instances Here, Codd tables Query language: here, relational algebra
Definition (Strong representation system) For any query in the language,
on uncertain instances represented in the framework, the uncertain instance obtained by evaluating the query can also be represented in the framework.
→ Are Codd tables astrong representation system?
SQL Semantics V-tables c-tables
Representation system definition
Uncertain instance: set of possible worlds Uncertainty framework: concise way to represent
uncertain instances Here, Codd tables Query language: here, relational algebra
Definition (Strong representation system) For any query in the language,
on uncertain instances represented in the framework, the uncertain instance obtained by evaluating the query can also be represented in the framework.
→ Are Codd tables astrong representation system?
SQL Semantics V-tables c-tables
Representation system definition
Uncertain instance: set of possible worlds Uncertainty framework: concise way to represent
uncertain instances Here, Codd tables Query language: here, relational algebra
Definition (Strong representation system) For any query in the language,
on uncertain instances represented in the framework,
the uncertain instance obtained by evaluating the query can also be represented in the framework.
→ Are Codd tables astrong representation system?
SQL Semantics V-tables c-tables
Representation system definition
Uncertain instance: set of possible worlds Uncertainty framework: concise way to represent
uncertain instances Here, Codd tables Query language: here, relational algebra
Definition (Strong representation system) For any query in the language,
on uncertain instances represented in the framework, the uncertain instance obtained by evaluating the query
can also be represented in the framework.
→ Are Codd tables astrong representation system?
SQL Semantics V-tables c-tables
Representation system definition
Uncertain instance: set of possible worlds Uncertainty framework: concise way to represent
uncertain instances Here, Codd tables Query language: here, relational algebra
Definition (Strong representation system) For any query in the language,
on uncertain instances represented in the framework, the uncertain instance obtained by evaluating the query can also be represented in the framework.
→ Are Codd tables astrong representation system?
SQL Semantics V-tables c-tables
Representation system definition
Uncertain instance: set of possible worlds Uncertainty framework: concise way to represent
uncertain instances Here, Codd tables Query language: here, relational algebra
Definition (Strong representation system) For any query in the language,
on uncertain instances represented in the framework, the uncertain instance obtained by evaluating the query can also be represented in the framework.
SQL Semantics V-tables c-tables
Are Codd tables a representation system?
Member id class
1 UDM
2 UDM
3 IE
Booking
date teacher class room 2015-12-07 Antoine UDM NULL
Can we representMember ▷◁Booking? Member▷◁Booking
id date teacher class room 1 2015-12-07 Antoine UDM NULL 2 2015-12-07 Antoine UDM NULL
→ Can you spot the problem?
SQL Semantics V-tables c-tables
Are Codd tables a representation system?
Member id class
1 UDM
2 UDM
3 IE
Booking
date teacher class room 2015-12-07 Antoine UDM NULL
Can we representMember ▷◁Booking?
Member▷◁Booking
id date teacher class room 1 2015-12-07 Antoine UDM NULL 2 2015-12-07 Antoine UDM NULL
→ Can you spot the problem?
SQL Semantics V-tables c-tables
Are Codd tables a representation system?
Member id class
1 UDM
2 UDM
3 IE
Booking
date teacher class room 2015-12-07 Antoine UDM NULL
Can we representMember ▷◁Booking?
Member▷◁Booking
id date teacher class room 1 2015-12-07 Antoine UDM NULL 2 2015-12-07 Antoine UDM NULL
→ Can you spot the problem?
SQL Semantics V-tables c-tables
Are Codd tables a representation system?
Member id class
1 UDM
2 UDM
3 IE
Booking
date teacher class room 2015-12-07 Antoine UDM NULL
Can we representMember ▷◁Booking?
Member▷◁Booking
id date teacher class room 1 2015-12-07 Antoine UDM NULL 2 2015-12-07 Antoine UDM NULL
SQL Semantics V-tables c-tables
Multiple values
When querying Codd tables, we may duplicateNULLs
→ We cannot represent that two NULLs are the same This may causeproblems!
SQL Semantics V-tables c-tables
Multiple values example
Booking
date teacher class room 2015-12-07 Antoine UDM NULL 2015-12-14 Silviu UDM C47
Πroom(Booking)−Πroom(σteacher=“Antoine”(Booking))
According toSQL According tosemantics C47
But if we try to representintermediate expressions?
Πroom(Booking) Πroom(σteacher=“Antoine”(Booking)) NULL
C47
NULL
SQL Semantics V-tables c-tables
Multiple values example
Booking
date teacher class room 2015-12-07 Antoine UDM NULL 2015-12-14 Silviu UDM C47
Πroom(Booking)−Πroom(σteacher=“Antoine”(Booking)) According to SQL According tosemantics
C47
But if we try to representintermediate expressions?
Πroom(Booking) Πroom(σteacher=“Antoine”(Booking)) NULL
C47
NULL
SQL Semantics V-tables c-tables
Multiple values example
Booking
date teacher class room 2015-12-07 Antoine UDM NULL 2015-12-14 Silviu UDM C47
Πroom(Booking)−Πroom(σteacher=“Antoine”(Booking)) According to SQL According tosemantics
C47
But if we try to representintermediate expressions?
Πroom(Booking) Πroom(σteacher=“Antoine”(Booking)) NULL
C47
NULL
SQL Semantics V-tables c-tables
Multiple values example
Booking
date teacher class room 2015-12-07 Antoine UDM NULL 2015-12-14 Silviu UDM C47
Πroom(Booking)−Πroom(σteacher=“Antoine”(Booking)) According to SQL According tosemantics
C47
But if we try to representintermediate expressions?
Πroom(Booking) Πroom(σteacher=“Antoine”(Booking))
NULL NULL
SQL Semantics V-tables c-tables
Table of contents
1 SQL
2 Semantics
3 V-tables
4 c-tables
SQL Semantics V-tables c-tables
v-tables
Idea: give each NULL itsown name
→ namedNULLs
Initially, all NULLs are distinct Propagate their identities
Member id class
1 UDM
2 UDM
3 IE
Booking
date teacher class room 2015-12-07 NULL1 UDM NULL2
Member▷◁Booking
id date teacher class room 1 2015-12-07 NULL1 UDM NULL2 2 2015-12-07 NULL1 UDM NULL2
SQL Semantics V-tables c-tables
v-tables
Idea: give each NULL itsown name
→ namedNULLs
Initially, all NULLs are distinct Propagate their identities
Member id class
1 UDM
2 UDM
3 IE
Booking
date teacher class room 2015-12-07 NULL1 UDM NULL2
Member▷◁Booking
id date teacher class room 1 2015-12-07 NULL1 UDM NULL2 2 2015-12-07 NULL1 UDM NULL2
SQL Semantics V-tables c-tables
v-tables
Idea: give each NULL itsown name
→ namedNULLs
Initially, all NULLs are distinct Propagate their identities
Member id class
1 UDM
2 UDM
3 IE
Booking
date teacher class room 2015-12-07 NULL1 UDM NULL2
Member▷◁Booking
id date teacher class room 1 2015-12-07 NULL1 UDM NULL2
SQL Semantics V-tables c-tables
v-table semantics
1 2015-12-07 NULL1 UDM NULL2 2 2015-12-07 NULL1 UDM NULL2
1 2015-12-07 aa UDM bb 2 2015-12-07 aa UDM bb
1 2015-12-07 ccc UDM ddd 2 2015-12-07 ccc UDM ddd
1 2015-12-07 e UDM e
2 2015-12-07 e UDM e
SQL Semantics V-tables c-tables
v-table semantics
1 2015-12-07 NULL1 UDM NULL2 2 2015-12-07 NULL1 UDM NULL2
1 2015-12-07 aa UDM bb 2 2015-12-07 aa UDM bb
1 2015-12-07 ccc UDM ddd 2 2015-12-07 ccc UDM ddd
1 2015-12-07 e UDM e
2 2015-12-07 e UDM e
SQL Semantics V-tables c-tables
v-table semantics
1 2015-12-07 NULL1 UDM NULL2 2 2015-12-07 NULL1 UDM NULL2
1 2015-12-07 aa UDM bb 2 2015-12-07 aa UDM bb
1 2015-12-07 ccc UDM ddd 2 2015-12-07 ccc UDM ddd
1 2015-12-07 e UDM e
2 2015-12-07 e UDM e
SQL Semantics V-tables c-tables
v-table semantics
1 2015-12-07 NULL1 UDM NULL2 2 2015-12-07 NULL1 UDM NULL2
1 2015-12-07 aa UDM bb 2 2015-12-07 aa UDM bb
1 2015-12-07 ccc UDM ddd 2 2015-12-07 ccc UDM ddd
1 2015-12-07 e UDM e
2 2015-12-07 e UDM e
SQL Semantics V-tables c-tables
Are v-tables a representation system?
Member id class
1 UDM
2 UDM
3 NULL0
Booking
date teacher class room 2015-12-07 NULL1 UDM NULL2
Member▷◁Booking id date teacher class room 1 2015-12-07 NULL1 UDM NULL2 2 2015-12-07 NULL1 UDM NULL2
3 2015-12-07 NULL1 UDM NULL2 ifNULL0 is “UDM”
SQL Semantics V-tables c-tables
Are v-tables a representation system?
Member id class
1 UDM
2 UDM
3 NULL0
Booking
date teacher class room 2015-12-07 NULL1 UDM NULL2
Member ▷◁Booking id date teacher class room 1 2015-12-07 NULL1 UDM NULL2 2 2015-12-07 NULL1 UDM NULL2
3 2015-12-07 NULL1 UDM NULL2 ifNULL0 is “UDM”
SQL Semantics V-tables c-tables
Problem
v-tables cannot represent optional rows
→ the number of rows iscertain
Whenselection,joinapplies to a NULL: we do not knowhow to evaluate
we areuncertainabout whether the tuple matches
→ Add conditions to rows!
SQL Semantics V-tables c-tables
Problem
v-tables cannot represent optional rows
→ the number of rows iscertain
Whenselection,joinapplies to a NULL:
we do not knowhow to evaluate
we areuncertainabout whether the tuple matches
→ Add conditions to rows!
SQL Semantics V-tables c-tables
Problem
v-tables cannot represent optional rows
→ the number of rows iscertain
Whenselection,joinapplies to a NULL:
we do not knowhow to evaluate
we areuncertainabout whether the tuple matches
→ Add conditions to rows!