• Aucun résultat trouvé

Uncertain Data Management NULLs

N/A
N/A
Protected

Academic year: 2022

Partager "Uncertain Data Management NULLs"

Copied!
169
0
0

Texte intégral

(1)

SQL Semantics V-tables c-tables

Uncertain Data Management NULLs

Antoine Amarilli1, Silviu Maniu2

1Télécom ParisTech

2LRI

November 30th, 2015

(2)

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.

(3)

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.

(4)

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.

(5)

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

(6)

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

(7)

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

(8)

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

(9)

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!

(10)

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!

(11)

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!

(12)

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

(13)

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

(14)

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

(15)

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

(16)

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

(17)

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

(18)

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

(19)

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

(20)

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

(21)

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

(22)

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

(23)

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

(24)

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

(25)

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

(26)

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

(27)

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

(28)

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

(29)

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

(30)

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

(31)

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

(32)

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

(33)

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

(34)

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

(35)

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

(36)

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

(37)

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

(38)

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

(39)

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

(40)

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

(41)

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

(42)

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

(43)

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!

(44)

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!

(45)

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!

(46)

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)

(47)

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)

(48)

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)

(49)

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)

(50)

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)

(51)

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)

(52)

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

(53)

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

(54)

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

(55)

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

(56)

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

(57)

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

(58)

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

(59)

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

(60)

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

(61)

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

(62)

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

(63)

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

(64)

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

(65)

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

(66)

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

(67)

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

(68)

SQL Semantics V-tables c-tables

Table of contents

1 SQL

2 Semantics

3 V-tables

4 c-tables

(69)

SQL Semantics V-tables c-tables

Semantics

We fix a signatureσ:

relationnames

associatedarity

We define uncertain interpretationsfor each relation

(70)

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

· · ·

(71)

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

· · ·

(72)

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

...

(73)

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

...

(74)

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

...

(75)

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

...

(76)

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

...

(77)

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

..

(78)

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

...

(79)

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

...

(80)

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

...

(81)

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

...

(82)

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?

(83)

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?

(84)

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

(85)

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

(86)

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

(87)

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

(88)

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

(89)

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

(90)

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

(91)

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?

(92)

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?

(93)

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?

(94)

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?

(95)

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?

(96)

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?

(97)

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?

(98)

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.

(99)

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?

(100)

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?

(101)

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?

(102)

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

(103)

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!

(104)

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)Πroomteacher=“Antoine”(Booking))

According toSQL According tosemantics C47

But if we try to representintermediate expressions?

Πroom(Booking) Πroomteacher=“Antoine”(Booking)) NULL

C47

NULL

(105)

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)Πroomteacher=“Antoine”(Booking)) According to SQL According tosemantics

C47

But if we try to representintermediate expressions?

Πroom(Booking) Πroomteacher=“Antoine”(Booking)) NULL

C47

NULL

(106)

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)Πroomteacher=“Antoine”(Booking)) According to SQL According tosemantics

C47

But if we try to representintermediate expressions?

Πroom(Booking) Πroomteacher=“Antoine”(Booking)) NULL

C47

NULL

(107)

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)Πroomteacher=“Antoine”(Booking)) According to SQL According tosemantics

C47

But if we try to representintermediate expressions?

Πroom(Booking) Πroomteacher=“Antoine”(Booking))

NULL NULL

(108)

SQL Semantics V-tables c-tables

Table of contents

1 SQL

2 Semantics

3 V-tables

4 c-tables

(109)

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

(110)

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

(111)

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

(112)

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

(113)

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

(114)

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

(115)

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

(116)

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”

(117)

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”

(118)

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!

(119)

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!

(120)

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!

Références

Documents relatifs

FUNFZEHN

Given a signature R, let’s consider a classical first-order logic language with equality (FOL) over the decomposed signature R, as it has been defined in Sec- e tion 2; FOL has

The Fundamental Theorem of Calculus

Lorsque une demande de ressource est admise, les nœuds du réseau installent des classeurs qui sont utilisés pour reconnaître le trafic admis et des régulateurs qui sont utilisés

Le présent mémoire définit l’algorithme de chiffrement NULL et son utilisation avec l’encapsulation de charge utile de sécurité (ESP) IPsec [RFC2406] pour

the term in oqjoç is not determined by the field equations, but is part of the initial data. Consequently, evolution derivatives cannot be expressed solely in terms

As a simplification, and without loss of generality, the further condi- tion that the partial derivatives (i = 1-4), are continuous at S may be assumed since a

We do it because it makes more clear how the construction algorithm of the control function in [16] and Theorem 1.3 can also be applied to prove the interior null-controllability