• Aucun résultat trouvé

Uncertain Data Management NULLs

N/A
N/A
Protected

Academic year: 2022

Partager "Uncertain Data Management NULLs"

Copied!
170
0
0

Texte intégral

(1)

Uncertain Data Management NULLs

Antoine Amarilli1, Silviu Maniu2 November 21st, 2017

1Télécom ParisTech

2LRI

(2)

NULLs

Representmissing informationin a relation

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Saphir 2017-12-05 Antoine UDM NULL 2017-12-12 NULL UDM NULL

Other name: Codd tables

(3)

NULLs

Representmissing informationin a relation

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Saphir 2017-12-05 Antoine UDM NULL 2017-12-12 NULL UDM NULL

Other name: Codd tables

(4)

NULLs

Representmissing informationin a relation

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Saphir 2017-12-05 Antoine UDM NULL 2017-12-12 NULL UDM NULL

Other name: Codd tables

(5)

Semantics

EachNULLcan be replacedindependentlybyanydomain value

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Saphir 2017-12-05 Antoine UDM

2017-12-12 UDM

(6)

Semantics

EachNULLcan be replacedindependentlybyanydomain value

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Saphir 2017-12-05 Antoine UDM NULL 2017-12-12 NULL UDM NULL

(7)

Semantics

EachNULLcan be replacedindependentlybyanydomain value

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Saphir 2017-12-05 Antoine UDM B543 2017-12-12 Antoine UDM Saphir

(8)

Semantics

EachNULLcan be replacedindependentlybyanydomain value

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Saphir 2017-12-05 Antoine UDM xbecz 2017-12-12 gruiiik UDM buuuk

(9)

Tricky semantics

How can we evaluatequerieson Codd tables?

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Saphir 2017-12-05 Antoine UDM NULL 2017-12-12 NULL UDM NULL SELECT * FROM Booking WHERE teacher='Silviu';

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir

→ Trickysemantics, oftencriticized!

(10)

Tricky semantics

How can we evaluatequerieson Codd tables?

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Saphir 2017-12-05 Antoine UDM NULL 2017-12-12 NULL UDM NULL SELECT * FROM Booking WHERE teacher='Silviu';

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir

→ Trickysemantics, oftencriticized!

(11)

Tricky semantics

How can we evaluatequerieson Codd tables?

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Saphir 2017-12-05 Antoine UDM NULL 2017-12-12 NULL UDM NULL SELECT * FROM Booking WHERE teacher='Silviu';

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir

→ Trickysemantics, oftencriticized!

(12)

Tricky semantics

How can we evaluatequerieson Codd tables?

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Saphir 2017-12-05 Antoine UDM NULL 2017-12-12 NULL UDM NULL SELECT * FROM Booking WHERE teacher='Silviu';

Booking

date teacher class room 2017-11-21 Silviu UDM Saphir

(13)

Three-valued logic

Usually, we evaluate operations asBoolean:

WHERE a=’42’ OR (b=c AND NOT (c=d))

WHERE False OR (True AND NOT (True))

False

In SQL, values can beTrue,False, orUnknown(NULL)

Essentiallyanythingthat involvesNULLisNULL

(14)

Three-valued logic

Usually, we evaluate operations asBoolean:

WHERE a=’42’ OR (b=c AND NOT (c=d))

WHERE False OR (True AND NOT (True))

False

In SQL, values can beTrue,False, orUnknown(NULL)

Essentiallyanythingthat involvesNULLisNULL

(15)

Three-valued logic

Usually, we evaluate operations asBoolean:

WHERE a=’42’ OR (b=c AND NOT (c=d))

WHERE False OR (True AND NOT (True))

False

In SQL, values can beTrue,False, orUnknown(NULL)

Essentiallyanythingthat involvesNULLisNULL

(16)

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)

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)

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)

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)

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)

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)

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)

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)

Three-valued logic (AND table)

AND True False

NULL

True True False

NULL

False False False

False NULL NULL False NULL

(25)

Three-valued logic (AND table)

AND True False NULL True True False

NULL

False False False

False

NULL

NULL False NULL

(26)

Three-valued logic (AND table)

AND True False NULL True True False

NULL

False False False False NULL

NULL

False

NULL

(27)

Three-valued logic (AND table)

AND True False NULL True True False NULL False False False False NULL NULL False NULL

(28)

Three-valued logic (OR table)

OR True False

NULL

True True True

True

False True False

NULL NULL True NULL NULL

(29)

Three-valued logic (OR table)

OR True False NULL True True True

True

False True False

NULL

NULL

True NULL NULL

(30)

Three-valued logic (OR table)

OR True False NULL True True True True False True False

NULL

NULL True

NULL NULL

(31)

Three-valued logic (OR table)

OR True False NULL True True True True False True False NULL NULL True NULL NULL

(32)

Three-valued logic (traps)

What isNULL* 42?

NULL

What isNULL/ 0?

Implementation-dependent:NULLorerror

What isNULL= NULL?

NULL

What does the following do?

SELECT * FROM Booking WHERE room=NULL

Returns anempty result

What does the following do?

SELECT * FROM Booking WHERE room='C42' OR room<>'C42'

Return everything whereroomisnotNULL

(33)

Three-valued logic (traps)

What isNULL* 42?

NULL

What isNULL/ 0?

Implementation-dependent:NULLorerror

What isNULL= NULL?

NULL

What does the following do?

SELECT * FROM Booking WHERE room=NULL

Returns anempty result

What does the following do?

SELECT * FROM Booking WHERE room='C42' OR room<>'C42'

Return everything whereroomisnotNULL

(34)

Three-valued logic (traps)

What isNULL* 42?

NULL

What isNULL/ 0?

Implementation-dependent:NULLorerror

What isNULL= NULL?

NULL

What does the following do?

SELECT * FROM Booking WHERE room=NULL

Returns anempty result

What does the following do?

SELECT * FROM Booking WHERE room='C42' OR room<>'C42'

Return everything whereroomisnotNULL

(35)

Three-valued logic (traps)

What isNULL* 42?

NULL

What isNULL/ 0?

Implementation-dependent:NULLorerror

What isNULL= NULL?

NULL

What does the following do?

SELECT * FROM Booking WHERE room=NULL

Returns anempty result

What does the following do?

SELECT * FROM Booking WHERE room='C42' OR room<>'C42'

Return everything whereroomisnotNULL

(36)

Three-valued logic (traps)

What isNULL* 42?

NULL

What isNULL/ 0?

Implementation-dependent:NULLorerror

What isNULL= NULL?

NULL

What does the following do?

SELECT * FROM Booking WHERE room=NULL

Returns anempty result

What does the following do?

SELECT * FROM Booking WHERE room='C42' OR room<>'C42'

Return everything whereroomisnotNULL

(37)

Three-valued logic (traps)

What isNULL* 42?

NULL

What isNULL/ 0?

Implementation-dependent:NULLorerror

What isNULL= NULL?

NULL

What does the following do?

SELECT * FROM Booking WHERE room=NULL

Returns anempty result

What does the following do?

SELECT * FROM Booking WHERE room='C42' OR room<>'C42'

Return everything whereroomisnotNULL

(38)

Three-valued logic (traps)

What isNULL* 42?

NULL

What isNULL/ 0?

Implementation-dependent:NULLorerror

What isNULL= NULL?

NULL

What does the following do?

SELECT * FROM Booking WHERE room=NULL

Returns anempty result

What does the following do?

SELECT * FROM Booking WHERE room='C42' OR room<>'C42'

Return everything whereroomisnotNULL

(39)

Three-valued logic (traps)

What isNULL* 42?

NULL

What isNULL/ 0?

Implementation-dependent:NULLorerror

What isNULL= NULL?

NULL

What does the following do?

SELECT * FROM Booking WHERE room=NULL

Returns anempty result

What does the following do?

SELECT * FROM Booking WHERE room='C42' OR room<>'C42'

Return everything whereroomisnotNULL

(40)

Three-valued logic (traps)

What isNULL* 42?

NULL

What isNULL/ 0?

Implementation-dependent:NULLorerror

What isNULL= NULL?

NULL

What does the following do?

SELECT * FROM Booking WHERE room=NULL

Returns anempty result

What does the following do?

SELECT * FROM Booking WHERE room='C42' OR room<>'C42'

Return everything whereroomisnotNULL

(41)

Three-valued logic (traps)

What isNULL* 42?

NULL

What isNULL/ 0?

Implementation-dependent:NULLorerror

What isNULL= NULL?

NULL

What does the following do?

SELECT * FROM Booking WHERE room=NULL

Returns anempty result

What does the following do?

SELECT * FROM Booking WHERE room='C42' OR room<>'C42'

Return everything whereroomisnotNULL

(42)

Three-valued logic (fixes)

IS NULL

test if an expression isNULL

Law ofexcluded fourth:

[COND] IS TRUE OR [COND] IS FALSE OR [COND] IS NULL

(43)

Three-valued logic (more complaints)

This issillyin terms of semantics!

Booking

date teacher class room 2017-12-05 Antoine UDM NULL

SELECT * FROM Booking WHERE room='C42' OR room<>'C42'

Possible worlds:

EithertheNULLis’C42’

...ortheNULLis something else

→ ...sothe tuple shouldmatchin either case!

(44)

Three-valued logic (more complaints)

This issillyin terms of semantics!

Booking

date teacher class room 2017-12-05 Antoine UDM NULL

SELECT * FROM Booking WHERE room='C42' OR room<>'C42' Possible worlds:

EithertheNULLis’C42’

...ortheNULLis something else

→ ...sothe tuple shouldmatchin either case!

(45)

Three-valued logic (more complaints)

This issillyin terms of semantics!

Booking

date teacher class room 2017-12-05 Antoine UDM NULL

SELECT * FROM Booking WHERE room='C42' OR room<>'C42' Possible worlds:

EithertheNULLis’C42’

...ortheNULLis something else

→ ...sothe tuple shouldmatchin either case!

(46)

Three-valued logic (more traps!) Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Jade 2017-12-05 Antoine UDM NULL

Repairs room cause C42 lavatory leak NULL leopard

SELECT * FROM Booking WHERE room NOT IN (SELECT room FROM Repairs)

→ Empty result!

SELECT * FROM Booking WHERE room NOT IN

(SELECT room FROM Repairs WHERE room IS NOT NULL)

→ Doesnotcontain theNULLfor 2017-12-05 SELECT * FROM Booking WHERE

(room IN (SELECT room FROM Repairs) IS NOT TRUE)

(47)

Three-valued logic (more traps!) Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Jade 2017-12-05 Antoine UDM NULL

Repairs room cause C42 lavatory leak NULL leopard

SELECT * FROM Booking WHERE room NOT IN (SELECT room FROM Repairs)

→ Empty result!

SELECT * FROM Booking WHERE room NOT IN

(SELECT room FROM Repairs WHERE room IS NOT NULL)

→ Doesnotcontain theNULLfor 2017-12-05 SELECT * FROM Booking WHERE

(room IN (SELECT room FROM Repairs) IS NOT TRUE)

(48)

Three-valued logic (more traps!) Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Jade 2017-12-05 Antoine UDM NULL

Repairs room cause C42 lavatory leak NULL leopard

SELECT * FROM Booking WHERE room NOT IN (SELECT room FROM Repairs)

→ Empty result!

SELECT * FROM Booking WHERE room NOT IN

(SELECT room FROM Repairs WHERE room IS NOT NULL)

→ Doesnotcontain theNULLfor 2017-12-05 SELECT * FROM Booking WHERE

(room IN (SELECT room FROM Repairs) IS NOT TRUE)

(49)

Three-valued logic (more traps!) Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Jade 2017-12-05 Antoine UDM NULL

Repairs room cause C42 lavatory leak NULL leopard

SELECT * FROM Booking WHERE room NOT IN (SELECT room FROM Repairs)

→ Empty result!

SELECT * FROM Booking WHERE room NOT IN

(SELECT room FROM Repairs WHERE room IS NOT NULL)

→ Doesnotcontain theNULLfor 2017-12-05 SELECT * FROM Booking WHERE

(room IN (SELECT room FROM Repairs) IS NOT TRUE)

(50)

Three-valued logic (more traps!) Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Jade 2017-12-05 Antoine UDM NULL

Repairs room cause C42 lavatory leak NULL leopard

SELECT * FROM Booking WHERE room NOT IN (SELECT room FROM Repairs)

→ Empty result!

SELECT * FROM Booking WHERE room NOT IN

(SELECT room FROM Repairs WHERE room IS NOT NULL)

→ Doesnotcontain theNULLfor 2017-12-05 SELECT * FROM Booking WHERE

(room IN (SELECT room FROM Repairs) IS NOT TRUE)

(51)

Three-valued logic (more traps!) Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Jade 2017-12-05 Antoine UDM NULL

Repairs room cause C42 lavatory leak NULL leopard

SELECT * FROM Booking WHERE room NOT IN (SELECT room FROM Repairs)

→ Empty result!

SELECT * FROM Booking WHERE room NOT IN

(SELECT room FROM Repairs WHERE room IS NOT NULL)

→ Doesnotcontain theNULLfor 2017-12-05

SELECT * FROM Booking WHERE

(room IN (SELECT room FROM Repairs) IS NOT TRUE)

(52)

Three-valued logic (more traps!) Booking

date teacher class room 2017-11-21 Silviu UDM Saphir 2017-11-28 Antoine UDM Jade 2017-12-05 Antoine UDM NULL

Repairs room cause C42 lavatory leak NULL leopard

SELECT * FROM Booking WHERE room NOT IN (SELECT room FROM Repairs)

→ Empty result!

SELECT * FROM Booking WHERE room NOT IN

(SELECT room FROM Repairs WHERE room IS NOT NULL)

→ Doesnotcontain theNULLfor 2017-12-05

(53)

Even more traps withNULLs

SELECT * FROM R NATURAL JOIN S

→ NULLswillneverjoin

SELECT a FROM R UNION SELECT a FROM S

→ multipleNULLswillnotbe kept (but withUNION ALL, they will)

SELECT DISTINCT a FROM R

→ multipleNULLswillnotbe kept

(54)

Even more traps withNULLs

SELECT * FROM R NATURAL JOIN S

→ NULLswillneverjoin

SELECT a FROM R UNION SELECT a FROM S

→ multipleNULLswillnotbe kept (but withUNION ALL, they will)

SELECT DISTINCT a FROM R

→ multipleNULLswillnotbe kept

(55)

Even more traps withNULLs

SELECT * FROM R NATURAL JOIN S

→ NULLswillneverjoin

SELECT a FROM R UNION SELECT a FROM S

→ multipleNULLswillnotbe kept (but withUNION ALL, they will)

SELECT DISTINCT a FROM R

→ multipleNULLswillnotbe kept

(56)

Even more traps withNULLs

SELECT * FROM R NATURAL JOIN S

→ NULLswillneverjoin

SELECT a FROM R UNION SELECT a FROM S

→ multipleNULLswillnotbe kept (but withUNION ALL, they will)

SELECT DISTINCT a FROM R

→ multipleNULLswillnotbe kept

(57)

Even more traps withNULLs

SELECT * FROM R NATURAL JOIN S

→ NULLswillneverjoin

SELECT a FROM R UNION SELECT a FROM S

→ multipleNULLswillnotbe kept (but withUNION ALL, they will)

SELECT DISTINCT a FROM R

→ multipleNULLswillnotbe kept

(58)

Even more traps withNULLs

SELECT * FROM R NATURAL JOIN S

→ NULLswillneverjoin

SELECT a FROM R UNION SELECT a FROM S

→ multipleNULLswillnotbe kept (but withUNION ALL, they will)

SELECT DISTINCT a FROM R

→ multipleNULLswillnotbe kept

(59)

Even, even more traps aboutNULLs SELECT COUNT(*) FROM R

→ NULLswillbe counted

SELECT COUNT(a) FROM R

→ NULLswillbeignored!

SELECT SUM(a) FROM R

→ NULLswill beignored

SELECT AVG(a),SUM(a)/COUNT(*) FROM R

→ values maydiffer

(60)

Even, even more traps aboutNULLs

SELECT COUNT(*) FROM R

→ NULLswillbe counted

SELECT COUNT(a) FROM R

→ NULLswillbeignored!

SELECT SUM(a) FROM R

→ NULLswill beignored

SELECT AVG(a),SUM(a)/COUNT(*) FROM R

→ values maydiffer

(61)

Even, even more traps aboutNULLs

SELECT COUNT(*) FROM R

→ NULLswillbe counted

SELECT COUNT(a) FROM R

→ NULLswillbeignored!

SELECT SUM(a) FROM R

→ NULLswill beignored

SELECT AVG(a),SUM(a)/COUNT(*) FROM R

→ values maydiffer

(62)

Even, even more traps aboutNULLs

SELECT COUNT(*) FROM R

→ NULLswillbe counted

SELECT COUNT(a) FROM R

→ NULLswillbeignored!

SELECT SUM(a) FROM R

→ NULLswill beignored

SELECT AVG(a),SUM(a)/COUNT(*) FROM R

→ values maydiffer

(63)

Even, even more traps aboutNULLs

SELECT COUNT(*) FROM R

→ NULLswillbe counted

SELECT COUNT(a) FROM R

→ NULLswillbeignored!

SELECT SUM(a) FROM R

→ NULLswill beignored

SELECT AVG(a),SUM(a)/COUNT(*) FROM R

→ values maydiffer

(64)

Even, even more traps aboutNULLs

SELECT COUNT(*) FROM R

→ NULLswillbe counted

SELECT COUNT(a) FROM R

→ NULLswillbeignored!

SELECT SUM(a) FROM R

→ NULLswill beignored

SELECT AVG(a),SUM(a)/COUNT(*) FROM R

→ values maydiffer

(65)

Even, even more traps aboutNULLs

SELECT COUNT(*) FROM R

→ NULLswillbe counted

SELECT COUNT(a) FROM R

→ NULLswillbeignored!

SELECT SUM(a) FROM R

→ NULLswill beignored

SELECT AVG(a),SUM(a)/COUNT(*) FROM R

→ values maydiffer

(66)

Even, even more traps aboutNULLs

SELECT COUNT(*) FROM R

→ NULLswillbe counted

SELECT COUNT(a) FROM R

→ NULLswillbeignored!

SELECT SUM(a) FROM R

→ NULLswill beignored

SELECT AVG(a),SUM(a)/COUNT(*) FROM R

(67)

Table of contents

SQL

Semantics

V-tables c-tables

(68)

Semantics

We fix asignatureσ:

relationnames

associatedarity

Uncertain instance:each relation name is interpreted by anuncertain relation

(69)

Uncertain relation

Anuncertain relation: set ofpossible worlds, each possible world is a relation in the usual sense

Booking date tch room

21 S. a

Booking date tch room

21 S. b

Booking date tch room

21 S. c

· · ·

This is an uncertain relation withinfinitely manypossible worlds, each of which containsone tuple

(70)

Uncertain relation

Anuncertain relation: set ofpossible worlds, each possible world is a relation in the usual sense

Booking date tch room

21 S. a

Booking date tch room

21 S. b

Booking date tch room

21 S. c

· · ·

This is an uncertain relation withinfinitely manypossible worlds, each of which containsone tuple

(71)

Uncertain relation

Anuncertain relation: set ofpossible worlds, each possible world is a relation in the usual sense

Booking date tch room

21 S. a

Booking date tch room

21 S. b

Booking date tch room

21 S. c

· · ·

This is an uncertain relation withinfinitely manypossible worlds, each of which containsone tuple

(72)

Relational algebra

Extend relational algebra operators touncertain relations

Thepossible worldsof theresultshould be...

• take allpossible worldsof the inputs

• apply the operation and get apossible output

Booking 21 S. a

Booking 21 S. b

Booking 21 S. c

...

Booking 28 a Saphir

Booking 28 b Saphir

Booking 28 c Saphir

...

=

Booking 21 S. a 28 b Saphir

Booking 21 S. b 28 a Saphir

...

(73)

Relational algebra

Extend relational algebra operators touncertain relations

Thepossible worldsof theresultshould be...

• take allpossible worldsof the inputs

• apply the operation and get apossible output Booking

21 S. a Booking 21 S. b

Booking 21 S. c

...

Booking 28 a Saphir

Booking 28 b Saphir

Booking 28 c Saphir

...

=

Booking 21 S. a 28 b Saphir

Booking 21 S. b 28 a Saphir

...

(74)

Relational algebra

Extend relational algebra operators touncertain relations

Thepossible worldsof theresultshould be...

• take allpossible worldsof the inputs

• apply the operation and get apossible output Booking

21 S. a Booking 21 S. b

Booking 21 S. c

Booking 28 a Saphir

Booking 28 b Saphir

Booking 28 c Saphir

...

=

Booking 21 S. a 28 b Saphir

Booking 21 S. b 28 a Saphir

...

(75)

Relational algebra

Extend relational algebra operators touncertain relations

Thepossible worldsof theresultshould be...

• take allpossible worldsof the inputs

• apply the operation and get apossible output Booking

21 S. a Booking 21 S. b

Booking 21 S. c

...

Booking 28 a Saphir

Booking 28 b Saphir

Booking 28 c Saphir

...

=

Booking 21 S. a 28 b Saphir

Booking 21 S. b 28 a Saphir

...

(76)

Relational algebra

Extend relational algebra operators touncertain relations

Thepossible worldsof theresultshould be...

• take allpossible worldsof the inputs

• apply the operation and get apossible output Booking

21 S. a Booking 21 S. b

Booking 21 S. c

Booking 28 a Saphir

Booking 28 b Saphir

Booking 28 c Saphir

=

Booking 21 S. a 28 b Saphir

Booking 21 S. b 28 a Saphir

...

(77)

Relational algebra

Extend relational algebra operators touncertain relations

Thepossible worldsof theresultshould be...

• take allpossible worldsof the inputs

• apply the operation and get apossible output Booking

21 S. a Booking 21 S. b

Booking 21 S. c

...

Booking 28 a Saphir

Booking 28 b Saphir

Booking 28 c Saphir

...

=

Booking 21 S. a 28 b Saphir

Booking 21 S. b 28 a Saphir

...

(78)

Representation system

Tables withNULLare arepresentationof uncertain tables

Booking

21 S. NULL stands for

Booking 21 S. a

Booking 21 S. b

Booking 21 S. c

...

(79)

Representation system

Tables withNULLare arepresentationof uncertain tables

Booking 21 S. NULL

stands for

Booking 21 S. a

Booking 21 S. b

Booking 21 S. c

...

(80)

Representation system

Tables withNULLare arepresentationof uncertain tables

Booking

21 S. NULL stands for

Booking 21 S. a

Booking 21 S. b

Booking 21 S. c

...

(81)

Representation system

Tables withNULLare arepresentationof uncertain tables

Booking

21 S. NULL stands for

Booking 21 S. a

Booking 21 S. b

Booking 21 S. c

...

(82)

Back to the silly example

Booking

date teacher class room 2017-12-12 Antoine UDM NULL 2018-01-09 Silviu UDM Sap.

SELECT * FROM Booking WHERE teacher='Antoine' AND (room='C42' OR room<>'C42')

→ How torepresentthe result?

(83)

Back to the silly example

Booking

date teacher class room 2017-12-12 Antoine UDM NULL 2018-01-09 Silviu UDM Sap.

SELECT * FROM Booking WHERE teacher='Antoine' AND (room='C42' OR room<>'C42')

→ How torepresentthe result?

(84)

Representing the output

12 A. UDM NULL 09 S. UDM Sap.

represents 12 A. UDM a

09 S. UDM Sap.

12 A. UDM b 09 S. UDM Sap.

12 A. UDM C42 09 S. UDM Sap. · · · SELECT * FROM Booking WHERE teacher='A.' AND

(room='C42' OR room<>'C42')

12 A. UDM a 12 A. UDM b 12 A. UDM C42 · · · represented as

12 A. UDM NULL

(85)

Representing the output

12 A. UDM NULL 09 S. UDM Sap.

represents

12 A. UDM a 09 S. UDM Sap.

12 A. UDM b 09 S. UDM Sap.

12 A. UDM C42 09 S. UDM Sap. · · · SELECT * FROM Booking WHERE teacher='A.' AND

(room='C42' OR room<>'C42')

12 A. UDM a 12 A. UDM b 12 A. UDM C42 · · · represented as

12 A. UDM NULL

(86)

Representing the output

12 A. UDM NULL 09 S. UDM Sap.

represents 12 A. UDM a

09 S. UDM Sap.

12 A. UDM b 09 S. UDM Sap.

12 A. UDM C42 09 S. UDM Sap. · · ·

SELECT * FROM Booking WHERE teacher='A.' AND (room='C42' OR room<>'C42')

12 A. UDM a 12 A. UDM b 12 A. UDM C42 · · · represented as

12 A. UDM NULL

(87)

Representing the output

12 A. UDM NULL 09 S. UDM Sap.

represents 12 A. UDM a

09 S. UDM Sap.

12 A. UDM b 09 S. UDM Sap.

12 A. UDM C42 09 S. UDM Sap. · · · SELECT * FROM Booking WHERE teacher='A.' AND

(room='C42' OR room<>'C42')

12 A. UDM a 12 A. UDM b 12 A. UDM C42 · · · represented as

12 A. UDM NULL

(88)

Representing the output

12 A. UDM NULL 09 S. UDM Sap.

represents 12 A. UDM a

09 S. UDM Sap.

12 A. UDM b 09 S. UDM Sap.

12 A. UDM C42 09 S. UDM Sap. · · · SELECT * FROM Booking WHERE teacher='A.' AND

(room='C42' OR room<>'C42')

12 A. UDM a 12 A. UDM b 12 A. UDM C42 · · ·

represented as 12 A. UDM NULL

(89)

Representing the output

12 A. UDM NULL 09 S. UDM Sap.

represents 12 A. UDM a

09 S. UDM Sap.

12 A. UDM b 09 S. UDM Sap.

12 A. UDM C42 09 S. UDM Sap. · · · SELECT * FROM Booking WHERE teacher='A.' AND

(room='C42' OR room<>'C42')

12 A. UDM a 12 A. UDM b 12 A. UDM C42 · · · represented as

12 A. UDM NULL

(90)

Representing the output

12 A. UDM NULL 09 S. UDM Sap.

represents 12 A. UDM a

09 S. UDM Sap.

12 A. UDM b 09 S. UDM Sap.

12 A. UDM C42 09 S. UDM Sap. · · · SELECT * FROM Booking WHERE teacher='A.' AND

(room='C42' OR room<>'C42')

12 A. UDM a 12 A. UDM b 12 A. UDM C42 · · · represented as

(91)

Representation system definition

Uncertain relation : set of possible worlds

Uncertainty framework: short way to represent uncertain relations

Here,Codd tables Query language: here, relational algebra Definition (Strong representation system) For any query in the language,

on uncertain relations represented in the framework, the uncertain relation obtained by evaluating the query can also be represented in the framework

→ Are Codd tables astrong representation system?

(92)

Representation system definition

Uncertain relation : set of possible worlds

Uncertainty framework: short way to represent uncertain relations

Here,Codd tables

Query language: here, relational algebra Definition (Strong representation system) For any query in the language,

on uncertain relations represented in the framework, the uncertain relation obtained by evaluating the query can also be represented in the framework

→ Are Codd tables astrong representation system?

(93)

Representation system definition

Uncertain relation : set of possible worlds

Uncertainty framework: short way to represent uncertain relations

Here,Codd tables Query language: here, relational algebra

Definition (Strong representation system) For any query in the language,

on uncertain relations represented in the framework, the uncertain relation obtained by evaluating the query can also be represented in the framework

→ Are Codd tables astrong representation system?

(94)

Representation system definition

Uncertain relation : set of possible worlds

Uncertainty framework: short way to represent uncertain relations

Here,Codd tables Query language: here, relational algebra Definition (Strong representation system) For any query in the language,

on uncertain relations represented in the framework, the uncertain relation obtained by evaluating the query can also be represented in the framework

→ Are Codd tables astrong representation system?

(95)

Representation system definition

Uncertain relation : set of possible worlds

Uncertainty framework: short way to represent uncertain relations

Here,Codd tables Query language: here, relational algebra Definition (Strong representation system) For any query in the language,

on uncertain relations represented in the framework,

the uncertain relation obtained by evaluating the query can also be represented in the framework

→ Are Codd tables astrong representation system?

(96)

Representation system definition

Uncertain relation : set of possible worlds

Uncertainty framework: short way to represent uncertain relations

Here,Codd tables Query language: here, relational algebra Definition (Strong representation system) For any query in the language,

on uncertain relations represented in the framework, the uncertain relation obtained by evaluating the query

can also be represented in the framework

→ Are Codd tables astrong representation system?

(97)

Representation system definition

Uncertain relation : set of possible worlds

Uncertainty framework: short way to represent uncertain relations

Here,Codd tables Query language: here, relational algebra Definition (Strong representation system) For any query in the language,

on uncertain relations represented in the framework, the uncertain relation obtained by evaluating the query can also be represented in the framework

→ Are Codd tables astrong representation system?

(98)

Representation system definition

Uncertain relation : set of possible worlds

Uncertainty framework: short way to represent uncertain relations

Here,Codd tables Query language: here, relational algebra Definition (Strong representation system) For any query in the language,

on uncertain relations represented in the framework, the uncertain relation obtained by evaluating the query can also be represented in the framework

→ Are Codd tables astrong representation system?

(99)

Are Codd tables a representation system?

Member id class

1 UDM

2 UDM

3 IE

Booking

date teacher class room 2017-12-05 Antoine UDM NULL

Can we representMember./Booking? Member./Booking

id date teacher class room 1 2017-12-05 Antoine UDM NULL 2 2017-12-05 Antoine UDM NULL

→ Can you spot theproblem?

(100)

Are Codd tables a representation system?

Member id class

1 UDM

2 UDM

3 IE

Booking

date teacher class room 2017-12-05 Antoine UDM NULL

Can we representMember./Booking?

Member./Booking

id date teacher class room 1 2017-12-05 Antoine UDM NULL 2 2017-12-05 Antoine UDM NULL

→ Can you spot theproblem?

(101)

Are Codd tables a representation system?

Member id class

1 UDM

2 UDM

3 IE

Booking

date teacher class room 2017-12-05 Antoine UDM NULL

Can we representMember./Booking?

Member./Booking

id date teacher class room 1 2017-12-05 Antoine UDM NULL 2 2017-12-05 Antoine UDM NULL

→ Can you spot theproblem?

(102)

Are Codd tables a representation system?

Member id class

1 UDM

2 UDM

3 IE

Booking

date teacher class room 2017-12-05 Antoine UDM NULL

Can we representMember./Booking?

Member./Booking

id date teacher class room 1 2017-12-05 Antoine UDM NULL 2 2017-12-05 Antoine UDM NULL

(103)

Multiple values

When querying Codd tables, we mayduplicateNULLs

→ We cannot represent that twoNULLsare thesame

This may causeproblems!

(104)

Multiple values example

Booking

date teacher class room 2017-12-12 Antoine UDM NULL 2018-01-09 Silviu UDM Saphir

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

According toSQL According tosemantics Saphir

But if we try to representintermediate expressions? Πroom(Booking) Πroomteacher=“Antoine”(Booking))

NULL Saphir

NULL

(105)

Multiple values example

Booking

date teacher class room 2017-12-12 Antoine UDM NULL 2018-01-09 Silviu UDM Saphir

Πroom(Booking)−Πroomteacher=“Antoine”(Booking)) According toSQL According tosemantics

Saphir

But if we try to representintermediate expressions? Πroom(Booking) Πroomteacher=“Antoine”(Booking))

NULL Saphir

NULL

(106)

Multiple values example

Booking

date teacher class room 2017-12-12 Antoine UDM NULL 2018-01-09 Silviu UDM Saphir

Πroom(Booking)−Πroomteacher=“Antoine”(Booking)) According toSQL According tosemantics

Saphir

But if we try to representintermediate expressions?

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

Saphir

NULL

(107)

Multiple values example

Booking

date teacher class room 2017-12-12 Antoine UDM NULL 2018-01-09 Silviu UDM Saphir

Πroom(Booking)−Πroomteacher=“Antoine”(Booking)) According toSQL According tosemantics

Saphir

But if we try to representintermediate expressions?

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

Saphir

NULL

(108)

Table of contents

SQL Semantics V-tables

c-tables

(109)

v-tables

Idea: give eachNULLitsown name, i.e.,namedNULLs

Initially, allNULLsaredistinct

Propagate theiridentities

Member id class

1 UDM

2 UDM

3 IE

Booking

date teacher class room 2017-12-05 NULL1 UDM NULL2

Member./Booking

id date teacher class room 1 2017-12-05 NULL1 UDM NULL2

2 2017-12-05 NULL1 UDM NULL2

(110)

v-tables

Idea: give eachNULLitsown name, i.e.,namedNULLs

Initially, allNULLsaredistinct

Propagate theiridentities Member

id class

1 UDM

2 UDM

3 IE

Booking

date teacher class room 2017-12-05 NULL1 UDM NULL2

Member./Booking

id date teacher class room 1 2017-12-05 NULL1 UDM NULL2

2 2017-12-05 NULL1 UDM NULL2

(111)

v-tables

Idea: give eachNULLitsown name, i.e.,namedNULLs

Initially, allNULLsaredistinct

Propagate theiridentities Member

id class

1 UDM

2 UDM

3 IE

Booking

date teacher class room 2017-12-05 NULL1 UDM NULL2

Member./Booking

id date teacher class room 1 2017-12-05 NULL1 UDM NULL2

(112)

v-table semantics

1 2017-12-05 NULL1 UDM NULL2

2 2017-12-05 NULL1 UDM NULL2

represents

1 2017-12-05 aa UDM bb 2 2017-12-05 aa UDM bb 1 2017-12-05 ccc UDM ddd 2 2017-12-05 ccc UDM ddd 1 2017-12-05 e UDM e 2 2017-12-05 e UDM e

...

(113)

v-table semantics

1 2017-12-05 NULL1 UDM NULL2

2 2017-12-05 NULL1 UDM NULL2

represents

1 2017-12-05 aa UDM bb 2 2017-12-05 aa UDM bb 1 2017-12-05 ccc UDM ddd 2 2017-12-05 ccc UDM ddd 1 2017-12-05 e UDM e 2 2017-12-05 e UDM e

...

(114)

Are v-tables a representation system?

Member id class

1 UDM

2 UDM

3 IE

Booking

date teacher class room 2017-12-05 Antoine UDM NULL1

Can we representMember./Bookingas a v-table? Member./Booking

id date teacher class room 1 2017-12-05 Antoine UDM NULL1

2 2017-12-05 Antoine UDM NULL1

(115)

Are v-tables a representation system?

Member id class

1 UDM

2 UDM

3 IE

Booking

date teacher class room 2017-12-05 Antoine UDM NULL1

Can we representMember./Bookingas a v-table?

Member./Booking

id date teacher class room 1 2017-12-05 Antoine UDM NULL1

2 2017-12-05 Antoine UDM NULL1

(116)

Are v-tables a representation system?

Member id class

1 UDM

2 UDM

3 IE

Booking

date teacher class room 2017-12-05 Antoine UDM NULL1

Can we representMember./Bookingas a v-table?

Member./Booking

id date teacher class room 1 2017-12-05 Antoine UDM NULL1

2 2017-12-05 Antoine UDM NULL

(117)

Are v-tables a representation system? (2)

Member id class

1 UDM

2 UDM

3 NULL0

Booking

date teacher class room 2017-12-05 NULL1 UDM NULL2

Member./Booking id date teacher class room 1 2017-12-05 NULL1 UDM NULL2

2 2017-12-05 NULL1 UDM NULL2

3 2017-12-05 NULL1 UDM NULL2 ifNULL0is “UDM”

(118)

Are v-tables a representation system? (2)

Member id class

1 UDM

2 UDM

3 NULL0

Booking

date teacher class room 2017-12-05 NULL1 UDM NULL2

Member./Booking id date teacher class room 1 2017-12-05 NULL1 UDM NULL2

2 2017-12-05 NULL1 UDM NULL2

3 2017-12-05 NULL1 UDM NULL2 ifNULL0is “UDM”

(119)

Problem

v-tables cannot representoptional rows

the number of rows iscertain

Whenselection,joinapplies to aNULL:

• we do not knowhow to evaluate

• we areuncertainabout whether the tuple matches

→ Addconditionsto rows!

(120)

Problem

v-tables cannot representoptional rows

the number of rows iscertain

Whenselection,joinapplies to aNULL:

• we do not knowhow to evaluate

• we areuncertainabout whether the tuple matches

→ Addconditionsto rows!

(121)

Problem

v-tables cannot representoptional rows

the number of rows iscertain

Whenselection,joinapplies to aNULL:

• we do not knowhow to evaluate

• we areuncertainabout whether the tuple matches

→ Addconditionsto rows!

(122)

Condition example

R··= Πid,room Member./Booking id room condition

1 NULL2

2 NULL2

3 NULL2 ifNULL0 is “UDM”

Rooms room seats C42 20 NULL3 25

R./Rooms id room seats condition 1 NULL2 20 ifNULL2is “C42” 1 NULL2 25 ifNULL2isNULL3

2 NULL2 20 ifNULL2is “C42” 2 NULL2 25 ifNULL2isNULL3

3 NULL2 20 ifNULL2is “C42” andNULL0is “UDM” 3 NULL2 25 ifNULL2isNULL3andNULL0is “UDM”

(123)

Condition example

R··= Πid,room Member./Booking id room condition

1 NULL2

2 NULL2

3 NULL2 ifNULL0 is “UDM”

Rooms room seats C42 20 NULL3 25

R./Rooms id room seats condition

1 NULL2 20 ifNULL2is “C42” 1 NULL2 25 ifNULL2isNULL3

2 NULL2 20 ifNULL2is “C42” 2 NULL2 25 ifNULL2isNULL3

3 NULL2 20 ifNULL2is “C42” andNULL0is “UDM” 3 NULL2 25 ifNULL2isNULL3andNULL0is “UDM”

(124)

Condition example

R··= Πid,room Member./Booking id room condition

1 NULL2

2 NULL2

3 NULL2 ifNULL0 is “UDM”

Rooms room seats C42 20 NULL3 25

R./Rooms id room seats condition 1 NULL2 20 ifNULL2is “C42”

1 NULL2 25 ifNULL2isNULL3

2 NULL2 20 ifNULL2is “C42” 2 NULL2 25 ifNULL2isNULL3

3 NULL2 20 ifNULL2is “C42” andNULL0is “UDM” 3 NULL2 25 ifNULL2isNULL3andNULL0is “UDM”

(125)

Condition example

R··= Πid,room Member./Booking id room condition

1 NULL2

2 NULL2

3 NULL2 ifNULL0 is “UDM”

Rooms room seats C42 20 NULL3 25

R./Rooms id room seats condition 1 NULL2 20 ifNULL2is “C42”

1 NULL2 25 ifNULL2isNULL3

2 NULL2 20 ifNULL2is “C42”

2 NULL2 25 ifNULL2isNULL3

3 NULL2 20 ifNULL2is “C42” andNULL0is “UDM” 3 NULL2 25 ifNULL2isNULL3andNULL0is “UDM”

(126)

Condition example

R··= Πid,room Member./Booking id room condition

1 NULL2

2 NULL2

3 NULL2 ifNULL0 is “UDM”

Rooms room seats C42 20 NULL3 25

R./Rooms id room seats condition 1 NULL2 20 ifNULL2is “C42”

1 NULL2 25 ifNULL2isNULL3

2 NULL2 20 ifNULL2is “C42”

2 NULL2 25 ifNULL2isNULL3

3 NULL 20

(127)

Table of contents

SQL Semantics V-tables c-tables

(128)

c-tables

NamedNULLs, plusconditionson tuples

Conditions can use:

true

false

NULLi=NULLj

NULLi= “value”

Booleanoperators

→ Arec-tablesastrong representation system?

(129)

c-tables

NamedNULLs, plusconditionson tuples

Conditions can use:

true

false

NULLi=NULLj

NULLi= “value”

Booleanoperators

→ Arec-tablesastrong representation system?

(130)

c-tables

NamedNULLs, plusconditionson tuples

Conditions can use:

true

false

NULLi=NULLj

NULLi= “value”

Booleanoperators

→ Arec-tablesastrong representation system?

(131)

c-tables

NamedNULLs, plusconditionson tuples

Conditions can use:

true

false

NULLi=NULLj

NULLi= “value”

Booleanoperators

→ Arec-tablesastrong representation system?

(132)

c-tables

NamedNULLs, plusconditionson tuples

Conditions can use:

true

false

NULLi=NULLj

NULLi= “value”

Booleanoperators

→ Arec-tablesastrong representation system?

(133)

c-tables

NamedNULLs, plusconditionson tuples

Conditions can use:

true

false

NULLi=NULLj

NULLi= “value”

Booleanoperators

→ Arec-tablesastrong representation system?

(134)

Relational algebra operators: product

S s condition s1 C1

s2 C2

T t condition t1 D1

t2 D2

S×T s t condition

s1 t1 C1 andD1

s1 t2 C1 andD2

s2 t1 C2 andD1

s2 t2 C2 andD2

(135)

Relational algebra operators: product

S s condition s1 C1

s2 C2

T t condition t1 D1

t2 D2

S×T s t condition

s1 t1 C1 andD1

s1 t2 C1 andD2

s2 t1 C2 andD1

s2 t2 C2 andD2

Références

Documents relatifs

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 also show the related but easier results that if G is a path, then for any matrix M e M(G) of corank 1, the null space kerM of M yields an embedding of G in the line; furthermore,

FUNFZEHN

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

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

“The place and function of Venus in Ovid...”. “Computed backscattering function of Venus and