






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







University of Maryland, College Park
!"#$ ' %"&&&&'&$()
!"#$! "&&&&&$()
()# %&'# !"##$*
Sensor Data Fusion
and Aggregation
!+,-.#
,-./! '"
12234567&
.6&8.975::
;($
/#",0&0)+'
(-,
()# 3#*
Possibly stale data,
from untrusted sources
'($ <#65&=:
%"0&>?"0&3@&
#A.B5&3C&<.)6&=:D
%"0&><=D
*"0&>,8D
<.)6&=:& +- &
,.A&8:
'($
()# 3&# 5+'!$#'.#**
Probabilistic data
w/ complex correlations
Automatically extracted
imprecise data
5&"0)+' E&FB56&3@&7)5&C56C.G&H5A&4#7#&C.9G25C&H5G5&7.&(9A-3C)&4#7#&9C36/&3679373B5&H5--I45!654&3675G@#25CJ&
7)5&2.$(-5K@&C5$#6732#--L&43C(#G#75&$5#C9G5C&.@&4#7#&M9#-37L@&9625G7#367L&7L(32#--L&#CC.23#754&H37)&37&
$#N5&C56C.G&4#7#&@9C3.6@&#//G5/#73.6&#&2)#--56/36/&7#CN:
OO
5+'!$#'.#
'E!"($ >'"J&'"D ''&&&&!:* '"
'($ >'"J'"D '"&&&&":*
()# 6789:; (#"**
Data with confidence and
accuracy bounds
Everything can be modeled using random variables Normalization, probability-intervals etc can be used to combine the two
everything is probably doomed to fail
KISS
(Prithviraj Sen) Examples from Dalvi and Suciu, VLDB 2004
Proposed by Fuhr et al, more work recently by Dalvi and Suciu • The examples are from Dalvi, Suciu [VLDB04] • With each tuple, a probability of existence is associated
ries, aggre- uantifiers
. cs, which is ers and im- and this is o represent operators to S
= A B s
‘m’ 1 0. s
‘n’ 1 0. T
= C D t
1 ‘p’ 0. Figure 1: A probabilistic database D
database instance probability
A world is a fixed set of tuples – no uncertainty Assuming “independence”:
Tuple-level Uncertainty
Dalvi and Suciu
associated
ential/universal quantifiers
2
abilistic semantics, which is tand by both users and im- uery evaluation, and this is ur approach is to represent and modify the operators to of each output tuple. This tics in [13], and is quite effi- imple, the problem is that it evaluation ignores the com- n the probabilities of the in- probabilities computed this ases, and lead to incorrect karound is to use an inten- is much more complex and, tical. Our approach is dif- ery plans, searching for one luation is correct. We show es have a #P-complete data ilistic semantics, and hence xtensional plan. However, n practice do have a correct the 10 TPC/H queries fall in , we describe two techniques to choose a plan that avoids Carlo simulation algorithm, ut can guarantee arbitrarily ating examples in Sec. 2, de- and describe our techniques experiments and Sec. 10 de- conclude in Sec. 11. cepts and techniques of this mples. base In a probabilistic s a certain probability of e. Figure 1 shows a proba- two tables, S
p
p
ilities 0. 8 and 0 .5, and the robability 0 .6. We use the e that a table or a database e in this example that the obabilistic events, in which S
p
A B s
1
s
2
T
p
C D t
1
Figure 1: A probabilistic database D
p
p
database instance probability D
1
1
2
1
D
2
1
1
D 3 = {s 2 , t 1 } 0. D
4
1
D
5
1
2
D
6
1
D 7 = {s 2 } 0. D
8
(a) q(u) : −S
p
p
(b) q
pwd
p
answer probability {
′
′
∅ 0. (c) Figure 2: (a) The possible worlds for D
p
(b) a query q, and (c) its possible answers. the tuple probabilities, as we have assumed them to be independent. For example, the probability of D 2 is
1
1
2
We now illustrate query evaluation on probabilistic databases. Consider the conjunctive query q in Fig. 2 (b). Its meaning on D
p
shown in Fig. 2 (c). It is obtained by applying q to each deterministic database in pwd(D
p
the probabilities of all instances that return the same answer. In our example we have q(D
1
2
q(D
3
′
′
4
8
the probability of the answer being {
′
′
pwd
p
Notice that we have never used the structure of the query explicitly, but only applied it to deterministic databases taken from pwd(D
p
a similar semantics to any query q, no matter how complex, because we only need to know its meaning
Possible Worlds
ntial/universal quantifiers
2
bilistic semantics, which is and by both users and im- ery evaluation, and this is ur approach is to represent and modify the operators to of each output tuple. This tics in [13], and is quite effi- mple, the problem is that it evaluation ignores the com- the probabilities of the in- probabilities computed this ases, and lead to incorrect around is to use an inten- is much more complex and, ical. Our approach is dif- ry plans, searching for one uation is correct. We show s have a #P-complete data listic semantics, and hence xtensional plan. However, practice do have a correct he 10 TPC/H queries fall in we describe two techniques to choose a plan that avoids arlo simulation algorithm, t can guarantee arbitrarily ting examples in Sec. 2, de- and describe our techniques xperiments and Sec. 10 de- onclude in Sec. 11. cepts and techniques of this mples. ase In a probabilistic a certain probability of . Figure 1 shows a proba- two tables, S
p
p
lities 0. 8 and 0 .5, and the obability 0 .6. We use the that a table or a database e in this example that the obabilistic events, in which extensional [13]. bilistic database is a proba- S
p
A B s 1 ‘m’ 1 0. s
2
T
p
C D t
1
Figure 1: A probabilistic database D
p
p
database instance probability D
1
1
2
1
D
2
1
1
D
3
2
1
D
4
1
D
5
1
2
D
6
1
D 7 = {s 2 } 0. D
8
(a) q(u) : −S
p
p
(b) q
pwd
p
answer probability {
′
′
∅ 0. (c) Figure 2: (a) The possible worlds for D
p
(b) a query q, and (c) its possible answers. the tuple probabilities, as we have assumed them to be independent. For example, the probability of D
2
p
shown in Fig. 2 (c). It is obtained by applying q to each deterministic database in pwd(D
p
the probabilities of all instances that return the same answer. In our example we have q(D
1
2
q(D
3
′
′
4
8
the probability of the answer being {
′
′
pwd
p
Notice that we have never used the structure of the query explicitly, but only applied it to deterministic databases taken from pwd(D
p
a similar semantics to any query q, no matter how complex, because we only need to know its meaning on deterministic databases.
pwd p
Combine the results together somehow
D
B=C
Query execution
sub-queries, aggre- iversal quantifiers 2 . emantics, which is both users and im- uation, and this is ach is to represent ify the operators to output tuple. This 3], and is quite effi- e problem is that it n ignores the com- babilities of the in- ities computed this lead to incorrect is to use an inten- more complex and, r approach is dif- , searching for one S p = A B s 1 ‘m’ 1 0. s 2 ‘n’ 1 0. T p = C D t 1 1 ‘p’ 0. Figure 1: A probabilistic database D p pwd(D p ) = database instance probability D 1 = {s 1 , s 2 , t 1 } 0. D 2 = {s 1 , t 1 } 0. D 3 = {s 2 , t 1 } 0. D 4 = {t 1 } 0. D 5 = {s 1 , s 2 } 0. D 6 = {s 1 } 0. D 7 = {s 2 } 0. D 8 = φ 0. (a) q(u) : −S p (x, y), T p (z, u), y = z
{‘p’} {‘p’} {‘p’} {} {} {} {} {} ins, nested sub-queries, aggre- stential/universal quantifiers 2 . obabilistic semantics, which is erstand by both users and im- query evaluation, and this is Our approach is to represent a, and modify the operators to ies of each output tuple. This antics in [13], and is quite effi- s simple, the problem is that it al evaluation ignores the com- t in the probabilities of the in- he probabilities computed this t cases, and lead to incorrect orkaround is to use an inten- ch is much more complex and, actical. Our approach is dif- query plans, searching for one S p = A B s 1 ‘m’ 1 0. s 2 ‘n’ 1 0. T p = C D t 1 1 ‘p’ 0. Figure 1: A probabilistic database D p pwd(D p ) = database instance probability D 1 = {s 1 , s 2 , t 1 } 0. D 2 = {s 1 , t 1 } 0. D 3 = {s 2 , t 1 } 0. D 4 = {t 1 } 0. D 5 = {s 1 , s 2 } 0. D 6 = {s 1 } 0. D 7 = {s 2 } 0. D 8 = φ 0. (a) q(u) : −S p (x, y), T p (z, u), y = z (b) cluding queries with joins, nested sub-queries, aggre- gates, group-by, and existential/universal quantifiers 2 . Queries have now a probabilistic semantics, which is simple and easy to understand by both users and im- plementors. The main problem is query evaluation, and this is the focus of our paper. Our approach is to represent SQL queries in an algebra, and modify the operators to compute the probabilities of each output tuple. This is called extensional semantics in [13], and is quite effi- cient. While this sounds simple, the problem is that it doesn’t work: extensional evaluation ignores the com- plex correlations present in the probabilities of the in- termediate results and the probabilities computed this way are wrong in most cases, and lead to incorrect ranking. In [13], the workaround is to use an inten- sional semantics 3 , which is much more complex and, as we show here, impractical. Our approach is dif- ferent: we rewrite the query plans, searching for one where the extensional evaluation is correct. We show however that certain queries have a #P-complete data complexity under probabilistic semantics, and hence do not admit a correct extensional plan. However, many queries that occur in practice do have a correct extensional plan (8 out of the 10 TPC/H queries fall in this category). For others, we describe two techniques for evaluation: a heuristics to choose a plan that avoids large errors, and a Monte-Carlo simulation algorithm, which is more expensive but can guarantee arbitrarily small errors. Outline We give motivating examples in Sec. 2, de- S p = A B s 1 ‘m’ 1 0. s 2 ‘n’ 1 0. T p = C D t 1 1 ‘p’ 0. Figure 1: A probabilistic database D p pwd(D p ) = database instance probability D 1 = {s 1 , s 2 , t 1 } 0. D 2 = {s 1 , t 1 } 0. D 3 = {s 2 , t 1 } 0. D 4 = {t 1 } 0. D 5 = {s 1 , s 2 } 0. D 6 = {s 1 } 0. D 7 = {s 2 } 0. D 8 = φ 0. (a) q(u) : −S p (x, y), T p (z, u), y = z (b) q pwd (D p ) = answer probability { ′ p ′ } 0. ∅ 0. (c) Figure 2: (a) The possible worlds for D p in Figure 1, (b) a query q, and (c) its possible answers. the tuple probabilities, as we have assumed them to be independent. For example, the probability of D 2 is
D
B=C
Extensional: Example joins, nested sub-queries, aggre- xistential/universal quantifiers 2 . probabilistic semantics, which is derstand by both users and im- is query evaluation, and this is r. Our approach is to represent bra, and modify the operators to lities of each output tuple. This emantics in [13], and is quite effi- ds simple, the problem is that it onal evaluation ignores the com- ent in the probabilities of the in- d the probabilities computed this ost cases, and lead to incorrect workaround is to use an inten- hich is much more complex and, practical. Our approach is dif- e query plans, searching for one l evaluation is correct. We show queries have a #P-complete data babilistic semantics, and hence ect extensional plan. However, cur in practice do have a correct t of the 10 TPC/H queries fall in hers, we describe two techniques istics to choose a plan that avoids onte-Carlo simulation algorithm, ive but can guarantee arbitrarily otivating examples in Sec. 2, de- c. 3, and describe our techniques orts experiments and Sec. 10 de- We conclude in Sec. 11. n concepts and techniques of this e examples. atabase In a probabilistic has a certain probability of abase. Figure 1 shows a proba- with two tables, S p and T p : the obabilities 0. 8 and 0 .5, and the as probability 0 .6. We use the asize that a table or a database assume in this example that the nt probabilistic events, in which alled extensional [13]. robabilistic database is a proba- all database instances, which we nd denote pwd(D p ). Fig. 2 (a) le instances with non-zero prob- omputed by simply multiplying ict our discussion to SQL queries whose , not a bag or an ordered list. l and intensional semantics formally in S p = A B s 1 ‘m’ 1 0. s 2 ‘n’ 1 0. T p = C D t 1 1 ‘p’ 0. Figure 1: A probabilistic database D p pwd(D p ) = database instance probability D 1 = {s 1 , s 2 , t 1 } 0. D 2 = {s 1 , t 1 } 0. D 3 = {s 2 , t 1 } 0. D 4 = {t 1 } 0. D 5 = {s 1 , s 2 } 0. D 6 = {s 1 } 0. D 7 = {s 2 } 0. D 8 = φ 0. (a) q(u) : −S p (x, y), T p (z, u), y = z (b) q pwd (D p ) = answer probability { ′ p ′ } 0. ∅ 0. (c) Figure 2: (a) The possible worlds for D p in Figure 1, (b) a query q, and (c) its possible answers. the tuple probabilities, as we have assumed them to be independent. For example, the probability of D 2 is
. In this paper
B pr 1 (1 - (1 - 0.8)( (a) Π B (S p ) B C D 1 1 ‘p’ 0. (b) Π B (S p )! B=C T D prob ‘p’ 0. (c) ΠD(ΠB(S p ) !B=C Figure 4: Evaluation of Π D (Π B ( tions early (as shown in this exampl and other kinds of rewritings. Queries with uncertain mat evaluation on probabilistic databas problem in itself, our motivation co ing SQL queries with uncertain ma their results. We illustrate here with on the Stanford movie database[1]. SELECT DISTINCT F.titl FROM Director D, Films WHERE D.did = F.did and D.name ≈ ’Copolla and F.title ≈ ’rain m and F.year ≈ 1995 The predicates on the director na title and year are here uncertain. Our approach is to translate the lar query over a probabilistic databa the table Films is assigned a probab well it matches the predicates tit and year ≈ 1995. Several techniq exist already, and in this paper we ones: see Sec. 8. In all cases, the res tic table, denoted Films p
. Simila
predicate on Director generates ble Director p
. Then, we evaluate t
SELECT DISTINCT F.titl FROM Director p D, Films WHERE D.did = F.did This is similar to the query q
A B C D prob ‘m’ 1 1 ’p’ 0.80. 6 = 0. ‘n’ 1 1 ’p’ 0.50. 6 = 0. (a) S p !B=C T p D prob ‘p’ (1 - (1 - 0.48)(1 - 0.3)) = 0. (b) Π D (S p ! B=C T p ) Figure 3: Evaluation of ΠD(S p !B=C T p ) In this simple example q rank (D p ) contains a single tuple and the distinction between q pwd and q rank is blurred. To see this distinction clearer, consider an- other query, q 1 (x) : −S p (x, y), T p (z, y), y = z. Here q pwd 1 and q rank 1 are given by: q pwd 1 (D p ) = answer probability { ′ m ′ , ′ n ′ } 0. { ′ m ′ } 0. { ′ n ′ } 0. ∅ 0. q rank 1 (D p ) = D Rank ’m’ 0. ’n’ 0. For example, the rank probability of ′ m ′ is obtained as P r({ ′ m ′ , ′ n ′ }) + P r({ ′ m ′ }). In general, q pwd (D p ) may be exponentially large, while q rank (D p ) is sim- ply a set of tuples, which are sorted by Rank. The problem in this paper is now to compute q rank (D p ) efficiently. Extensional Query Semantics A natural at- tempt to compute q rank (D p ) is to represent q as a query plan then compute the probabilities of all tuples in all intermediate results. For the query q in Fig. 2 (b), such a plan is p = Π D (S p ! B=C T p ), and the cor- responding probabilities are shown in Fig. 3. The for- mulas for the probabilities assume tuple independence, are taken from [13] and are rather straightforward (we review them in Sec. 4). For example the probability of a joined tuple s! t is the product of the probabil- ities of s and t. Clearly, this approach is much more efficient than computing the possible worlds q pwd (D p ) and then computing q rank (D p ), but it is wrong! It’s answer is 0.636, while it should be 0.54. The reason is that the two tuples in S p ! B=C T p are not indepen- dent events, hence the formula used in ΠD is wrong. However, let us consider an alternative plan, p ′ = Π D ((Π B (S p ))! B=D T p ). The extensional evaluation B 1 (1 - (1 - 0 (a) Π B (S p B C D 1 1 ‘p’ (b) Π B (S p )! B= D prob ‘p’ 0. (c) Π D (Π B (S p )! B Figure 4: Evaluation of Π D ( tions early (as shown in this exam and other kinds of rewritings. Queries with uncertain m evaluation on probabilistic data problem in itself, our motivatio ing SQL queries with uncertain their results. We illustrate here on the Stanford movie database SELECT DISTINCT F.t FROM Director D, Fil WHERE D.did = F.did and D.name ≈ ’Copo and F.title ≈ ’rai and F.year ≈ 1995 The predicates on the directo title and year are here uncertain Our approach is to translate lar query over a probabilistic da the table Films is assigned a pro well it matches the predicates t and year ≈ 1995. Several tech exist already, and in this paper ones: see Sec. 8. In all cases, the tic table, denoted Films p
. Sim
predicate on Director generat ble Director p
. Then, we evalua
Umm.. This is wrong !! Why? The two tuples above are not independent.
Extensional: Example joins, nested sub-queries, aggre- xistential/universal quantifiers 2 . probabilistic semantics, which is derstand by both users and im- is query evaluation, and this is r. Our approach is to represent bra, and modify the operators to lities of each output tuple. This emantics in [13], and is quite effi- ds simple, the problem is that it onal evaluation ignores the com- ent in the probabilities of the in- d the probabilities computed this ost cases, and lead to incorrect workaround is to use an inten- hich is much more complex and, practical. Our approach is dif- e query plans, searching for one l evaluation is correct. We show queries have a #P-complete data babilistic semantics, and hence ect extensional plan. However, cur in practice do have a correct t of the 10 TPC/H queries fall in hers, we describe two techniques istics to choose a plan that avoids onte-Carlo simulation algorithm, ive but can guarantee arbitrarily otivating examples in Sec. 2, de- c. 3, and describe our techniques orts experiments and Sec. 10 de- We conclude in Sec. 11. n concepts and techniques of this e examples. atabase In a probabilistic has a certain probability of abase. Figure 1 shows a proba- with two tables, S p and T p : the obabilities 0. 8 and 0 .5, and the as probability 0 .6. We use the asize that a table or a database assume in this example that the nt probabilistic events, in which alled extensional [13]. robabilistic database is a proba- all database instances, which we nd denote pwd(D p ). Fig. 2 (a) le instances with non-zero prob- omputed by simply multiplying ict our discussion to SQL queries whose , not a bag or an ordered list. S p = A B s 1 ‘m’ 1 0. s 2 ‘n’ 1 0. T p = C D t 1 1 ‘p’ 0. Figure 1: A probabilistic database D p pwd(D p ) = database instance probability D 1 = {s 1 , s 2 , t 1 } 0. D 2 = {s 1 , t 1 } 0. D 3 = {s 2 , t 1 } 0. D 4 = {t 1 } 0. D 5 = {s 1 , s 2 } 0. D 6 = {s 1 } 0. D 7 = {s 2 } 0. D 8 = φ 0. (a) q(u) : −S p (x, y), T p (z, u), y = z (b) q pwd (D p ) = answer probability { ′ p ′ } 0. ∅ 0. (c) Figure 2: (a) The possible worlds for D p in Figure 1, (b) a query q, and (c) its possible answers. the tuple probabilities, as we have assumed them to be independent. For example, the probability of D 2 is
. In this paper
B pr 1 (1 - (1 - 0.8)( (a) ΠB(S p ) B C D 1 1 ‘p’ 0. (b) Π B (S p )! B=C T D prob ‘p’ 0. (c) Π D (Π B (S p )! B=C Figure 4: Evaluation of ΠD(ΠB( tions early (as shown in this exampl and other kinds of rewritings. Queries with uncertain mat evaluation on probabilistic databas problem in itself, our motivation co ing SQL queries with uncertain ma their results. We illustrate here with on the Stanford movie database[1]. SELECT DISTINCT F.titl FROM Director D, Films WHERE D.did = F.did and D.name ≈ ’Copolla and F.title ≈ ’rain m and F.year ≈ 1995 The predicates on the director na title and year are here uncertain. Our approach is to translate the lar query over a probabilistic databa the table Films is assigned a probab well it matches the predicates tit and year ≈ 1995. Several techniq exist already, and in this paper we ones: see Sec. 8. In all cases, the res tic table, denoted Films p
. Simila
predicate on Director generates ble Director p
. Then, we evaluate t
SELECT DISTINCT F.titl FROM Director p D, Films WHERE D.did = F.did This is similar to the query q
A B C D prob ‘m’ 1 1 ’p’ 0.80. 6 = 0. ‘n’ 1 1 ’p’ 0.50. 6 = 0. (a) S p ! B=C T p D prob ‘p’ (1 - (1 - 0.48)(1 - 0.3)) = 0. (b) ΠD(S p !B=C T p ) Figure 3: Evaluation of Π D (S p ! B=C T p ) In this simple example q rank (D p ) contains a single tuple and the distinction between q pwd and q rank is blurred. To see this distinction clearer, consider an- other query, q 1 (x) : −S p (x, y), T p (z, y), y = z. Here q pwd 1 and q rank 1 are given by: q pwd 1 (D p ) = answer probability { ′ m ′ , ′ n ′ } 0. { ′ m ′ } 0. { ′ n ′ } 0. ∅ 0. q rank 1 (D p ) = D Rank ’m’ 0. ’n’ 0. For example, the rank probability of ′ m ′ is obtained as P r({ ′ m ′ , ′ n ′ }) + P r({ ′ m ′ }). In general, q pwd (D p ) may be exponentially large, while q rank (D p ) is sim- ply a set of tuples, which are sorted by Rank. The problem in this paper is now to compute q rank (D p ) efficiently. Extensional Query Semantics A natural at- tempt to compute q rank (D p ) is to represent q as a query plan then compute the probabilities of all tuples in all intermediate results. For the query q in Fig. 2 (b), such a plan is p = Π D (S p ! B=C T p ), and the cor- responding probabilities are shown in Fig. 3. The for- mulas for the probabilities assume tuple independence, are taken from [13] and are rather straightforward (we review them in Sec. 4). For example the probability of a joined tuple s! t is the product of the probabil- ities of s and t. Clearly, this approach is much more efficient than computing the possible worlds q pwd (D p ) and then computing q rank (D p ), but it is wrong! It’s answer is 0.636, while it should be 0.54. The reason is that the two tuples in S p ! B=C T p are not indepen- dent events, hence the formula used in Π D is wrong. However, let us consider an alternative plan, p ′ = Π ((Π (S p ))! T p ). The extensional evaluation B 1 (1 - (1 - 0 (a) Π B (S p B C D 1 1 ‘p’ (b) Π B (S p )! B= D prob ‘p’ 0. (c) Π D (Π B (S p )! B Figure 4: Evaluation of Π D ( tions early (as shown in this exam and other kinds of rewritings. Queries with uncertain m evaluation on probabilistic data problem in itself, our motivatio ing SQL queries with uncertain their results. We illustrate here on the Stanford movie database SELECT DISTINCT F.t FROM Director D, Fil WHERE D.did = F.did and D.name ≈ ’Copo and F.title ≈ ’rai and F.year ≈ 1995 The predicates on the directo title and year are here uncertain Our approach is to translate lar query over a probabilistic da the table Films is assigned a pro well it matches the predicates t and year ≈ 1995. Several tech exist already, and in this paper ones: see Sec. 8. In all cases, the tic table, denoted Films p
. Sim
predicate on Director generat ble Director p
. Then, we evalua
Umm.. This is wrong !! Why? The two tuples above are not independent.
Extensional: Example joins, nested sub-queries, aggre- xistential/universal quantifiers 2 . probabilistic semantics, which is derstand by both users and im- is query evaluation, and this is r. Our approach is to represent bra, and modify the operators to lities of each output tuple. This emantics in [13], and is quite effi- ds simple, the problem is that it onal evaluation ignores the com- ent in the probabilities of the in- d the probabilities computed this ost cases, and lead to incorrect workaround is to use an inten- hich is much more complex and, practical. Our approach is dif- e query plans, searching for one l evaluation is correct. We show queries have a #P-complete data babilistic semantics, and hence ect extensional plan. However, cur in practice do have a correct t of the 10 TPC/H queries fall in hers, we describe two techniques istics to choose a plan that avoids onte-Carlo simulation algorithm, ive but can guarantee arbitrarily otivating examples in Sec. 2, de- c. 3, and describe our techniques orts experiments and Sec. 10 de- We conclude in Sec. 11. n concepts and techniques of this e examples. atabase In a probabilistic has a certain probability of abase. Figure 1 shows a proba- with two tables, S p and T p : the obabilities 0. 8 and 0 .5, and the as probability 0 .6. We use the asize that a table or a database assume in this example that the nt probabilistic events, in which alled extensional [13]. robabilistic database is a proba- all database instances, which we nd denote pwd(D p ). Fig. 2 (a) le instances with non-zero prob- omputed by simply multiplying ict our discussion to SQL queries whose , not a bag or an ordered list. S p = A B s 1 ‘m’ 1 0. s 2 ‘n’ 1 0. T p = C D t 1 1 ‘p’ 0. Figure 1: A probabilistic database D p pwd(D p ) = database instance probability D 1 = {s 1 , s 2 , t 1 } 0. D 2 = {s 1 , t 1 } 0. D 3 = {s 2 , t 1 } 0. D 4 = {t 1 } 0. D 5 = {s 1 , s 2 } 0. D 6 = {s 1 } 0. D 7 = {s 2 } 0. D 8 = φ 0. (a) q(u) : −S p (x, y), T p (z, u), y = z (b) q pwd (D p ) = answer probability { ′ p ′ } 0. ∅ 0. (c) Figure 2: (a) The possible worlds for D p in Figure 1, (b) a query q, and (c) its possible answers. the tuple probabilities, as we have assumed them to be independent. For example, the probability of D 2 is
. In this paper
B pr 1 (1 - (1 - 0.8)( (a) ΠB(S p ) B C D 1 1 ‘p’ 0. (b) ΠB(S p ) !B=C T D prob ‘p’ 0. (c) Π D (Π B (S p )! B=C Figure 4: Evaluation of ΠD(ΠB( tions early (as shown in this exampl and other kinds of rewritings. Queries with uncertain mat evaluation on probabilistic databas problem in itself, our motivation co ing SQL queries with uncertain ma their results. We illustrate here with on the Stanford movie database[1]. SELECT DISTINCT F.titl FROM Director D, Films WHERE D.did = F.did and D.name ≈ ’Copolla and F.title ≈ ’rain m and F.year ≈ 1995 The predicates on the director na title and year are here uncertain. Our approach is to translate the lar query over a probabilistic databa the table Films is assigned a probab well it matches the predicates tit and year ≈ 1995. Several techniq exist already, and in this paper we ones: see Sec. 8. In all cases, the res tic table, denoted Films p
. Simila
predicate on Director generates ble Director p
. Then, we evaluate t
SELECT DISTINCT F.titl FROM Director p D, Films WHERE D.did = F.did This is similar to the query q
A B C D prob ‘m’ 1 1 ’p’ 0.80. 6 = 0. ‘n’ 1 1 ’p’ 0.50. 6 = 0. (a) S p ! B=C T p D prob ‘p’ (1 - (1 - 0.48)(1 - 0.3)) = 0. (b) Π D (S p ! B=C T p ) Figure 3: Evaluation of Π D (S p ! B=C T p ) In this simple example q rank (D p ) contains a single tuple and the distinction between q pwd and q rank is blurred. To see this distinction clearer, consider an- other query, q 1 (x) : −S p (x, y), T p (z, y), y = z. Here q pwd 1 and q rank 1 are given by: q pwd 1 (D p ) = answer probability { ′ m ′ , ′ n ′ } 0. { ′ m ′ } 0. { ′ n ′ } 0. ∅ 0. q rank 1 (D p ) = D Rank ’m’ 0. ’n’ 0. For example, the rank probability of ′ m ′ is obtained as P r({ ′ m ′ , ′ n ′ }) + P r({ ′ m ′ }). In general, q pwd (D p ) may be exponentially large, while q rank (D p ) is sim- ply a set of tuples, which are sorted by Rank. The problem in this paper is now to compute q rank (D p ) efficiently. Extensional Query Semantics A natural at- tempt to compute q rank (D p ) is to represent q as a query plan then compute the probabilities of all tuples in all intermediate results. For the query q in Fig. 2 (b), such a plan is p = Π D (S p ! B=C T p ), and the cor- responding probabilities are shown in Fig. 3. The for- mulas for the probabilities assume tuple independence, are taken from [13] and are rather straightforward (we review them in Sec. 4). For example the probability of a joined tuple s! t is the product of the probabil- ities of s and t. Clearly, this approach is much more efficient than computing the possible worlds q pwd (D p ) and then computing q rank (D p ), but it is wrong! It’s answer is 0.636, while it should be 0.54. The reason is that the two tuples in S p !B=C T p are not indepen- dent events, hence the formula used in Π D is wrong. However, let us consider an alternative plan, p ′ = Π ((Π (S p ))! T p ). The extensional evaluation B 1 (1 - (1 - 0 (a) ΠB(S p B C D 1 1 ‘p’ (b) ΠB(S p ) !B= D prob ‘p’ 0. (c) Π D (Π B (S p )! B Figure 4: Evaluation of ΠD( tions early (as shown in this exam and other kinds of rewritings. Queries with uncertain m evaluation on probabilistic data problem in itself, our motivatio ing SQL queries with uncertain their results. We illustrate here on the Stanford movie database SELECT DISTINCT F.t FROM Director D, Fil WHERE D.did = F.did and D.name ≈ ’Copo and F.title ≈ ’rai and F.year ≈ 1995 The predicates on the directo title and year are here uncertain Our approach is to translate lar query over a probabilistic da the table Films is assigned a pro well it matches the predicates t and year ≈ 1995. Several tech exist already, and in this paper ones: see Sec. 8. In all cases, the tic table, denoted Films p
. Sim
predicate on Director generat ble Director p
. Then, we evalua
Umm.. This is wrong !! Why? The two tuples above are not independent.
Extensional: Example joins, nested sub-queries, aggre- xistential/universal quantifiers 2 . probabilistic semantics, which is derstand by both users and im- is query evaluation, and this is r. Our approach is to represent bra, and modify the operators to lities of each output tuple. This emantics in [13], and is quite effi- ds simple, the problem is that it onal evaluation ignores the com- ent in the probabilities of the in- d the probabilities computed this ost cases, and lead to incorrect workaround is to use an inten- hich is much more complex and, practical. Our approach is dif- e query plans, searching for one l evaluation is correct. We show queries have a #P-complete data babilistic semantics, and hence ect extensional plan. However, cur in practice do have a correct t of the 10 TPC/H queries fall in hers, we describe two techniques istics to choose a plan that avoids onte-Carlo simulation algorithm, ive but can guarantee arbitrarily otivating examples in Sec. 2, de- c. 3, and describe our techniques orts experiments and Sec. 10 de- We conclude in Sec. 11. n concepts and techniques of this e examples. atabase In a probabilistic has a certain probability of abase. Figure 1 shows a proba- with two tables, S p and T p : the obabilities 0. 8 and 0 .5, and the as probability 0 .6. We use the asize that a table or a database assume in this example that the nt probabilistic events, in which alled extensional [13]. robabilistic database is a proba- all database instances, which we nd denote pwd(D p ). Fig. 2 (a) le instances with non-zero prob- omputed by simply multiplying ict our discussion to SQL queries whose , not a bag or an ordered list. l and intensional semantics formally in S p = A B s 1 ‘m’ 1 0. s 2 ‘n’ 1 0. T p = C D t 1 1 ‘p’ 0. Figure 1: A probabilistic database D p pwd(D p ) = database instance probability D 1 = {s 1 , s 2 , t 1 } 0. D 2 = {s 1 , t 1 } 0. D 3 = {s 2 , t 1 } 0. D 4 = {t 1 } 0. D 5 = {s 1 , s 2 } 0. D 6 = {s 1 } 0. D 7 = {s 2 } 0. D 8 = φ 0. (a) q(u) : −S p (x, y), T p (z, u), y = z (b) q pwd (D p ) = answer probability { ′ p ′ } 0. ∅ 0. (c) Figure 2: (a) The possible worlds for D p in Figure 1, (b) a query q, and (c) its possible answers. the tuple probabilities, as we have assumed them to be independent. For example, the probability of D 2 is
. In this paper
B pr 1 (1 - (1 - 0.8)( (a) Π B (S p ) B C D 1 1 ‘p’ 0. (b) Π B (S p )! B=C T D prob ‘p’ 0. (c) ΠD(ΠB(S p ) !B=C Figure 4: Evaluation of Π D (Π B ( tions early (as shown in this exampl and other kinds of rewritings. Queries with uncertain mat evaluation on probabilistic databas problem in itself, our motivation co ing SQL queries with uncertain ma their results. We illustrate here with on the Stanford movie database[1]. SELECT DISTINCT F.titl FROM Director D, Films WHERE D.did = F.did and D.name ≈ ’Copolla and F.title ≈ ’rain m and F.year ≈ 1995 The predicates on the director na title and year are here uncertain. Our approach is to translate the lar query over a probabilistic databa the table Films is assigned a probab well it matches the predicates tit and year ≈ 1995. Several techniq exist already, and in this paper we ones: see Sec. 8. In all cases, the res tic table, denoted Films p
. Simila
predicate on Director generates ble Director p
. Then, we evaluate t
SELECT DISTINCT F.titl FROM Director p D, Films WHERE D.did = F.did This is similar to the query q
A B C D prob ‘m’ 1 1 ’p’ 0.80. 6 = 0. ‘n’ 1 1 ’p’ 0.50. 6 = 0. (a) S p !B=C T p D prob ‘p’ (1 - (1 - 0.48)(1 - 0.3)) = 0. (b) Π D (S p ! B=C T p ) Figure 3: Evaluation of ΠD(S p !B=C T p ) In this simple example q rank (D p ) contains a single tuple and the distinction between q pwd and q rank is blurred. To see this distinction clearer, consider an- other query, q 1 (x) : −S p (x, y), T p (z, y), y = z. Here q pwd 1 and q rank 1 are given by: q pwd 1 (D p ) = answer probability { ′ m ′ , ′ n ′ } 0. { ′ m ′ } 0. { ′ n ′ } 0. ∅ 0. q rank 1 (D p ) = D Rank ’m’ 0. ’n’ 0. For example, the rank probability of ′ m ′ is obtained as P r({ ′ m ′ , ′ n ′ }) + P r({ ′ m ′ }). In general, q pwd (D p ) may be exponentially large, while q rank (D p ) is sim- ply a set of tuples, which are sorted by Rank. The problem in this paper is now to compute q rank (D p ) efficiently. Extensional Query Semantics A natural at- tempt to compute q rank (D p ) is to represent q as a query plan then compute the probabilities of all tuples in all intermediate results. For the query q in Fig. 2 (b), such a plan is p = Π D (S p ! B=C T p ), and the cor- responding probabilities are shown in Fig. 3. The for- mulas for the probabilities assume tuple independence, are taken from [13] and are rather straightforward (we review them in Sec. 4). For example the probability of a joined tuple s! t is the product of the probabil- ities of s and t. Clearly, this approach is much more efficient than computing the possible worlds q pwd (D p ) and then computing q rank (D p ), but it is wrong! It’s answer is 0.636, while it should be 0.54. The reason is that the two tuples in S p ! B=C T p are not indepen- dent events, hence the formula used in ΠD is wrong. However, let us consider an alternative plan, p ′ = Π D ((Π B (S p ))! B=D T p ). The extensional evaluation B 1 (1 - (1 - 0 (a) Π B (S p B C D 1 1 ‘p’ (b) Π B (S p )! B= D prob ‘p’ 0. (c) Π D (Π B (S p )! B Figure 4: Evaluation of Π D ( tions early (as shown in this exam and other kinds of rewritings. Queries with uncertain m evaluation on probabilistic data problem in itself, our motivatio ing SQL queries with uncertain their results. We illustrate here on the Stanford movie database SELECT DISTINCT F.t FROM Director D, Fil WHERE D.did = F.did and D.name ≈ ’Copo and F.title ≈ ’rai and F.year ≈ 1995 The predicates on the directo title and year are here uncertain Our approach is to translate lar query over a probabilistic da the table Films is assigned a pro well it matches the predicates t and year ≈ 1995. Several tech exist already, and in this paper ones: see Sec. 8. In all cases, the tic table, denoted Films p
. Sim
predicate on Director generat ble Director p
. Then, we evalua
Umm.. This is wrong !! Why? The two tuples above are not independent.
D
B=C
Alternate Query Plan joins, nested sub-queries, aggre- xistential/universal quantifiers 2 . probabilistic semantics, which is derstand by both users and im- is query evaluation, and this is r. Our approach is to represent bra, and modify the operators to lities of each output tuple. This emantics in [13], and is quite effi- ds simple, the problem is that it onal evaluation ignores the com- ent in the probabilities of the in- d the probabilities computed this ost cases, and lead to incorrect workaround is to use an inten- hich is much more complex and, practical. Our approach is dif- e query plans, searching for one l evaluation is correct. We show queries have a #P-complete data babilistic semantics, and hence ect extensional plan. However, S p = A B s 1 ‘m’ 1 0. s 2 ‘n’ 1 0. T p = C D t 1 1 ‘p’ 0. Figure 1: A probabilistic database D p pwd(D p ) = database instance probability D 1 = {s 1 , s 2 , t 1 } 0. D 2 = {s 1 , t 1 } 0. D 3 = {s 2 , t 1 } 0. D 4 = {t 1 } 0. D 5 = {s 1 , s 2 } 0. D 6 = {s 1 } 0. D 7 = {s 2 } 0. D 8 = φ 0. (a) q(u) : −S p (x, y), T p (z, u), y = z (b) q pwd (D p ) = answer probability { ′ p ′ } 0. ∅ 0.
The correctness unfortunately depends on the plan used. Called “safe plans” [Dalvi, Suciu 2004] Projection: union probability; assume independence
prob 0.80. 6 = 0. 0.50. 6 = 0. B=C T^ p prob )(1 - 0.3)) = 0. !B=C T p ) of Π D (S p ! B=C T p ) q rank (D p ) contains a single between q pwd and q rank is ction clearer, consider an- x, y), T p (z, y), y = z. Here y: B prob 1 (1 - (1 - 0.8)(1 - 0.5)) = 0. (a) ΠB(S p ) B C D prob 1 1 ‘p’ 0.9 * 0.6 = 0. 54 (b) ΠB(S p ) !B=C T p D prob ‘p’ 0. (c) ΠD(ΠB(S p ) !B=C T p ) Figure 4: Evaluation of Π D (Π B (S p )! B=C T p )
prob ’ 0.80. 6 = 0. ’ 0.50. 6 = 0. !B=C T p prob 8)(1 - 0.3)) = 0. p !B=C T p ) n of ΠD(S p !B=C T p ) q rank (D p ) contains a single between q pwd and q rank is inction clearer, consider an- (x, y), T p (z, y), y = z. Here by: probability B prob 1 (1 - (1 - 0.8)(1 - 0.5)) = 0. (a) Π B (S p ) B C D prob 1 1 ‘p’ 0.9 * 0.6 = 0. 54 (b) Π B (S p )! B=C T p D prob ‘p’ 0. (c) Π D (Π B (S p )! B=C T p ) Figure 4: Evaluation of Π D (Π B (S p )! B=C T p )
D
B=C Intensional SemanticsT^ )^ →^ Do Join first, then Projection joins, nested sub-queries, aggre- xistential/universal quantifiers 2 . robabilistic semantics, which is derstand by both users and im- is query evaluation, and this is r. Our approach is to represent bra, and modify the operators to ities of each output tuple. This emantics in [13], and is quite effi- ds simple, the problem is that it onal evaluation ignores the com- ent in the probabilities of the in- the probabilities computed this ost cases, and lead to incorrect workaround is to use an inten- hich is much more complex and, practical. Our approach is dif- e query plans, searching for one l evaluation is correct. We show ueries have a #P-complete data babilistic semantics, and hence ect extensional plan. However, cur in practice do have a correct t of the 10 TPC/H queries fall in hers, we describe two techniques istics to choose a plan that avoids nte-Carlo simulation algorithm, ive but can guarantee arbitrarily otivating examples in Sec. 2, de- c. 3, and describe our techniques orts experiments and Sec. 10 de- We conclude in Sec. 11. concepts and techniques of this e examples. atabase In a probabilistic has a certain probability of base. Figure 1 shows a proba- ith two tables, S p and T p : the obabilities 0. 8 and 0 .5, and the as probability 0 .6. We use the asize that a table or a database ssume in this example that the t probabilistic events, in which alled extensional [13]. robabilistic database is a proba- all database instances, which we nd denote pwd(D p ). Fig. 2 (a) le instances with non-zero prob- omputed by simply multiplying ct our discussion to SQL queries whose , not a bag or an ordered list. l and intensional semantics formally in S p = A B s 1 ‘m’ 1 0. s 2 ‘n’ 1 0. T p = C D t 1 1 ‘p’ 0. Figure 1: A probabilistic database D p pwd(D p ) = database instance probability D 1 = {s 1 , s 2 , t 1 } 0. D 2 = {s 1 , t 1 } 0. D 3 = {s 2 , t 1 } 0. D 4 = {t 1 } 0. D 5 = {s 1 , s 2 } 0. D 6 = {s 1 } 0. D 7 = {s 2 } 0. D 8 = φ 0. (a) q(u) : −S p (x, y), T p (z, u), y = z (b) q pwd (D p ) = answer probability { ′ p ′ } 0. ∅ 0. (c) Figure 2: (a) The possible worlds for D p in Figure 1, (b) a query q, and (c) its possible answers. the tuple probabilities, as we have assumed them to be independent. For example, the probability of D 2 is
o the central problem, evaluating uery q, and a probabilistic database definition directly is infeasible, since ing over a large set of database in- we will first review the intensional then describe our approach. ur discussion first to conjunctive alternatively can be expressed as roject-join queries. This helps us bet- he query evaluation problem and its ill consider more complex query ex-
plans p in the select/project/product l Query Evaluation evaluating queries on probabilistic use complex events, and was intro- e review it here and discuss its limi- expressing q as a query plan, using , ×. Then modify each operator to nt attribute E in each intermediate , Π i , × i the modified operators. It is to introduce them in the functional y defining the complex event e p (t) for ctively on the query plan p: = { e p (t) if c(t) is true ⊥ if c(t) is false = ∨ t ′ :Π (^) ¯ A (t ′ )=t ep(t ′ ) (1) = ep(t) ∧ ep′^ (t ′ ) efinitions for σ i , Π i , × i follow easily: n copies the complex events from the he output tuples; Π i associates to a lex event e 1 ∨... ∨ e n obtained from A B C D E ‘m’ 1 1 ’p’ s 1 ∧ t 1 ‘n’ 1 1 ’p’ s 2 ∧ t 1 (a) S p ! i B=C T p D E ‘p’ (s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 ) (b) Π i D (S p ! i B=C T p ) D Rank ‘p ′ P r((s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 )) = 0. 54 (c) q rank (D p ) = P r(Π i D (S p ! i B=C T p )) Figure 5: Intensional Evaluation of Π D (S p ! B=C T p ) the complex events of all input tuples t 1 ,... , t n that project into t; and × i simply associates to a product tuple (t, t ′ ) the complex event e ∧ e ′ . Example 4. 1 Let us consider the database D p de- scribed in Figure 1. Consider the query plan, p = Π D (S p ! B=C T p ). Figure 5 shows the intensional evaluation of the query (we used the tuple names as atomic events). p i (D p ) contains a single tuple ′ p ′ with the event (s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 ). Thus, p i (D p ) denotes an intensional probabilistic relation. It can be shown that this is independent on the particular choice of plan p, and we denote q i (D p ) the value p i (D p ) for any plan p for q, and call it the in- tensional semantics 5 of q on the probabilistic database D p
. We prove now that it is equivalent to the possible
worlds semantics, q pwd (D p ). Theorem 4.2. The intensional semantics and the possible worlds semantics on probabilistic databases coincide for conjunctive queries. More precisely, pwd(q i (D p )) = q pwd (D p ) for every intensional prob- abilistic database D p and conjunctive query q. (All proofs in this paper are available in our techni- cal report [10].) Theorem 4.2 allows us to compute q rank (D p ), as follows. First compute q i (D p ), then compute the probability P r(e) for each complex event. Then q rank (D p ) = P r(q i (D p )). Example 4. 3 Fig. 5(c) shows p rank (D p ) for Ex. 4.1. P r((s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 )) was shown in Ex. 3.1. It is very impractical to use the intensional seman- tics to compute the rank probabilities, for two reasons. First, the event expressions in q i (D p ) can become very large. In the worst case the size of such an expres- sion can become of the same order of magnitude as the database. For instance, if a projection on a table
nting its probability. tion Problem This paper ad- roblem: given schema ¯ R p , Γ p , a D p and a query q over schema ilistic rankings q rank (D p ). eries with uncertain pred- deterministic database D and citly mentions some uncertain bles. We convert this problem rministic query q, obtained by predicates from q ≈ , on a prob- ined by associating a probabil- t based on how well t satisfies s in the query.
central problem, evaluating q, and a probabilistic database ition directly is infeasible, since er a large set of database in- ill first review the intensional describe our approach. iscussion first to conjunctive atively can be expressed as -join queries. This helps us bet- ery evaluation problem and its nsider more complex query ex- use either datalog notation for p in the select/project/product ery Evaluation ating queries on probabilistic mplex events, and was intro- ew it here and discuss its limi- essing q as a query plan, using Then modify each operator to ribute E in each intermediate i the modified operators. It is roduce them in the functional ing the complex event e p (t) for y on the query plan p: e p (t) if c(t) is true ⊥ if c(t) is false ∨ ′ :Π ¯ A (t ′ )=t ep(t ′ ) (1) ′ ′ A B C D E ‘m’ 1 1 ’p’ s 1 ∧ t 1 ‘n’ 1 1 ’p’ s 2 ∧ t 1 (a) S p ! i B=C T p D E ‘p’ (s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 ) (b) Π i D (S p ! i B=C T p ) D Rank ‘p ′ P r((s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 )) = 0. 54 (c) q rank (D p ) = P r(Π i D (S p ! i B=C T p )) Figure 5: Intensional Evaluation of ΠD (S p !B=C T p ) the complex events of all input tuples t 1 ,... , t n that project into t; and × i simply associates to a product tuple (t, t ′ ) the complex event e ∧ e ′ . Example 4. 1 Let us consider the database D p de- scribed in Figure 1. Consider the query plan, p = Π D (S p ! B=C T p ). Figure 5 shows the intensional evaluation of the query (we used the tuple names as atomic events). p i (D p ) contains a single tuple ′ p ′ with the event (s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 ). Thus, p i (D p ) denotes an intensional probabilistic relation. It can be shown that this is independent on the particular choice of plan p, and we denote q i (D p ) the value p i (D p ) for any plan p for q, and call it the in- tensional semantics 5 of q on the probabilistic database D p
. We prove now that it is equivalent to the possible
worlds semantics, q pwd (D p ). Theorem 4.2. The intensional semantics and the possible worlds semantics on probabilistic databases coincide for conjunctive queries. More precisely, pwd(q i (D p )) = q pwd (D p ) for every intensional prob- abilistic database D p and conjunctive query q. (All proofs in this paper are available in our techni- cal report [10].) Theorem 4.2 allows us to compute q rank (D p ), as follows. First compute q i (D p ), then compute the probability P r(e) for each complex event. Then q rank (D p ) = P r(q i (D p )). Example 4. 3 Fig. 5(c) shows p rank (D p ) for Ex. 4.1. P r((s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 )) was shown in Ex. 3.1.
This would result in the correct probability. Can also see correlations.
Intensional Semantics joins, nested sub-queries, aggre- xistential/universal quantifiers 2 . robabilistic semantics, which is derstand by both users and im- is query evaluation, and this is r. Our approach is to represent bra, and modify the operators to ities of each output tuple. This emantics in [13], and is quite effi- ds simple, the problem is that it onal evaluation ignores the com- ent in the probabilities of the in- the probabilities computed this ost cases, and lead to incorrect workaround is to use an inten- hich is much more complex and, practical. Our approach is dif- e query plans, searching for one l evaluation is correct. We show ueries have a #P-complete data babilistic semantics, and hence ect extensional plan. However, cur in practice do have a correct t of the 10 TPC/H queries fall in hers, we describe two techniques istics to choose a plan that avoids nte-Carlo simulation algorithm, ive but can guarantee arbitrarily otivating examples in Sec. 2, de- c. 3, and describe our techniques orts experiments and Sec. 10 de- We conclude in Sec. 11. concepts and techniques of this e examples. atabase In a probabilistic has a certain probability of base. Figure 1 shows a proba- ith two tables, S p and T p : the obabilities 0. 8 and 0 .5, and the as probability 0 .6. We use the asize that a table or a database ssume in this example that the t probabilistic events, in which alled extensional [13]. robabilistic database is a proba- all database instances, which we nd denote pwd(D p ). Fig. 2 (a) le instances with non-zero prob- omputed by simply multiplying ct our discussion to SQL queries whose , not a bag or an ordered list. l and intensional semantics formally in S p = A B s 1 ‘m’ 1 0. s 2 ‘n’ 1 0. T p = C D t 1 1 ‘p’ 0. Figure 1: A probabilistic database D p pwd(D p ) = database instance probability D 1 = {s 1 , s 2 , t 1 } 0. D 2 = {s 1 , t 1 } 0. D 3 = {s 2 , t 1 } 0. D 4 = {t 1 } 0. D 5 = {s 1 , s 2 } 0. D 6 = {s 1 } 0. D 7 = {s 2 } 0. D 8 = φ 0. (a) q(u) : −S p (x, y), T p (z, u), y = z (b) q pwd (D p ) = answer probability { ′ p ′ } 0. ∅ 0. (c) Figure 2: (a) The possible worlds for D p in Figure 1, (b) a query q, and (c) its possible answers. the tuple probabilities, as we have assumed them to be independent. For example, the probability of D 2 is
o the central problem, evaluating uery q, and a probabilistic database definition directly is infeasible, since ing over a large set of database in- we will first review the intensional then describe our approach. ur discussion first to conjunctive alternatively can be expressed as roject-join queries. This helps us bet- he query evaluation problem and its ill consider more complex query ex-
plans p in the select/project/product l Query Evaluation evaluating queries on probabilistic use complex events, and was intro- e review it here and discuss its limi- expressing q as a query plan, using , ×. Then modify each operator to nt attribute E in each intermediate , Π i , × i the modified operators. It is to introduce them in the functional y defining the complex event e p (t) for ctively on the query plan p: = { e p (t) if c(t) is true ⊥ if c(t) is false = ∨ t ′ :Π (^) ¯ A (t ′ )=t ep(t ′ ) (1) = ep(t) ∧ ep′^ (t ′ ) efinitions for σ i , Π i , × i follow easily: n copies the complex events from the he output tuples; Π i associates to a lex event e 1 ∨... ∨ e n obtained from A B C D E ‘m’ 1 1 ’p’ s 1 ∧ t 1 ‘n’ 1 1 ’p’ s 2 ∧ t 1 (a) S p ! i B=C T p D E ‘p’ (s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 ) (b) Π i D (S p ! i B=C T p ) D Rank ‘p ′ P r((s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 )) = 0. 54 (c) q rank (D p ) = P r(Π i D (S p ! i B=C T p )) Figure 5: Intensional Evaluation of ΠD (S p !B=C T p ) the complex events of all input tuples t 1 ,... , t n that project into t; and × i simply associates to a product tuple (t, t ′ ) the complex event e ∧ e ′ . Example 4. 1 Let us consider the database D p de- scribed in Figure 1. Consider the query plan, p = Π D (S p ! B=C T p ). Figure 5 shows the intensional evaluation of the query (we used the tuple names as atomic events). p i (D p ) contains a single tuple ′ p ′ with the event (s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 ). Thus, p i (D p ) denotes an intensional probabilistic relation. It can be shown that this is independent on the particular choice of plan p, and we denote q i (D p ) the value p i (D p ) for any plan p for q, and call it the in- tensional semantics 5 of q on the probabilistic database D p
. We prove now that it is equivalent to the possible
worlds semantics, q pwd (D p ). Theorem 4.2. The intensional semantics and the possible worlds semantics on probabilistic databases coincide for conjunctive queries. More precisely, pwd(q i (D p )) = q pwd (D p ) for every intensional prob- abilistic database D p and conjunctive query q. (All proofs in this paper are available in our techni- cal report [10].) Theorem 4.2 allows us to compute q rank (D p ), as follows. First compute q i (D p ), then compute the probability P r(e) for each complex event. Then q rank (D p ) = P r(q i (D p )). Example 4. 3 Fig. 5(c) shows p rank (D p ) for Ex. 4.1. P r((s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 )) was shown in Ex. 3.1. It is very impractical to use the intensional seman- tics to compute the rank probabilities, for two reasons. First, the event expressions in q i (D p ) can become very large. In the worst case the size of such an expres- sion can become of the same order of magnitude as the database. For instance, if a projection on a table
nting its probability. tion Problem This paper ad- roblem: given schema ¯ R p , Γ p , a D p and a query q over schema ilistic rankings q rank (D p ). eries with uncertain pred- deterministic database D and citly mentions some uncertain bles. We convert this problem rministic query q, obtained by predicates from q ≈ , on a prob- ined by associating a probabil- t based on how well t satisfies s in the query.
central problem, evaluating q, and a probabilistic database ition directly is infeasible, since er a large set of database in- ill first review the intensional describe our approach. iscussion first to conjunctive atively can be expressed as -join queries. This helps us bet- ery evaluation problem and its nsider more complex query ex- use either datalog notation for p in the select/project/product ery Evaluation ating queries on probabilistic mplex events, and was intro- ew it here and discuss its limi- essing q as a query plan, using Then modify each operator to ribute E in each intermediate i the modified operators. It is roduce them in the functional ing the complex event e p (t) for y on the query plan p: e p (t) if c(t) is true ⊥ if c(t) is false ∨ ′ :Π ¯ A (t ′ )=t ep(t ′ ) (1) (t) ∧ e ′^ (t ′ ) A B C D E ‘m’ 1 1 ’p’ s 1 ∧ t 1 ‘n’ 1 1 ’p’ s 2 ∧ t 1 (a) S p ! i B=C T p D E ‘p’ (s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 ) (b) Π i D (S p ! i B=C T p ) D Rank ‘p ′ P r((s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 )) = 0. 54 (c) q rank (D p ) = P r(Π i D (S p ! i B=C T p )) Figure 5: Intensional Evaluation of Π D (S p ! B=C T p ) the complex events of all input tuples t 1 ,... , t n that project into t; and × i simply associates to a product tuple (t, t ′ ) the complex event e ∧ e ′ . Example 4. 1 Let us consider the database D p de- scribed in Figure 1. Consider the query plan, p = Π D (S p ! B=C T p ). Figure 5 shows the intensional evaluation of the query (we used the tuple names as atomic events). p i (D p ) contains a single tuple ′ p ′ with the event (s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 ). Thus, p i (D p ) denotes an intensional probabilistic relation. It can be shown that this is independent on the particular choice of plan p, and we denote q i (D p ) the value p i (D p ) for any plan p for q, and call it the in- tensional semantics 5 of q on the probabilistic database D p
. We prove now that it is equivalent to the possible
worlds semantics, q pwd (D p ). Theorem 4.2. The intensional semantics and the possible worlds semantics on probabilistic databases coincide for conjunctive queries. More precisely, pwd(q i (D p )) = q pwd (D p ) for every intensional prob- abilistic database D p and conjunctive query q. (All proofs in this paper are available in our techni- cal report [10].) Theorem 4.2 allows us to compute q rank (D p ), as follows. First compute q i (D p ), then compute the probability P r(e) for each complex event. Then q rank (D p ) = P r(q i (D p )). Example 4. 3 Fig. 5(c) shows p rank (D p ) for Ex. 4.1. P r((s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 )) was shown in Ex. 3.1.
This would result in the correct probability. Can also see correlations.
Intensional Semantics joins, nested sub-queries, aggre- xistential/universal quantifiers 2 . robabilistic semantics, which is derstand by both users and im- is query evaluation, and this is r. Our approach is to represent bra, and modify the operators to ities of each output tuple. This mantics in [13], and is quite effi- ds simple, the problem is that it onal evaluation ignores the com- ent in the probabilities of the in- the probabilities computed this st cases, and lead to incorrect workaround is to use an inten- hich is much more complex and, practical. Our approach is dif- e query plans, searching for one evaluation is correct. We show ueries have a #P-complete data babilistic semantics, and hence ct extensional plan. However, ur in practice do have a correct t of the 10 TPC/H queries fall in hers, we describe two techniques stics to choose a plan that avoids nte-Carlo simulation algorithm, ve but can guarantee arbitrarily otivating examples in Sec. 2, de- c. 3, and describe our techniques orts experiments and Sec. 10 de- We conclude in Sec. 11. concepts and techniques of this e examples. atabase In a probabilistic has a certain probability of base. Figure 1 shows a proba- ith two tables, S p and T p : the obabilities 0. 8 and 0 .5, and the as probability 0 .6. We use the asize that a table or a database ssume in this example that the t probabilistic events, in which alled extensional [13]. robabilistic database is a proba- all database instances, which we nd denote pwd(D p ). Fig. 2 (a) le instances with non-zero prob- omputed by simply multiplying ct our discussion to SQL queries whose , not a bag or an ordered list. and intensional semantics formally in S p = A B s 1 ‘m’ 1 0. s 2 ‘n’ 1 0. T p = C D t 1 1 ‘p’ 0. Figure 1: A probabilistic database D p pwd(D p ) = database instance probability D 1 = {s 1 , s 2 , t 1 } 0. D 2 = {s 1 , t 1 } 0. D 3 = {s 2 , t 1 } 0. D 4 = {t 1 } 0. D 5 = {s 1 , s 2 } 0. D 6 = {s 1 } 0. D 7 = {s 2 } 0. D 8 = φ 0. (a) q(u) : −S p (x, y), T p (z, u), y = z (b) q pwd (D p ) = answer probability { ′ p ′ } 0. ∅ 0. (c) Figure 2: (a) The possible worlds for D p in Figure 1, (b) a query q, and (c) its possible answers. the tuple probabilities, as we have assumed them to be independent. For example, the probability of D 2 is
o the central problem, evaluating uery q, and a probabilistic database definition directly is infeasible, since ing over a large set of database in- we will first review the intensional then describe our approach. ur discussion first to conjunctive alternatively can be expressed as oject-join queries. This helps us bet- e query evaluation problem and its ill consider more complex query ex-
plans p in the select/project/product l Query Evaluation evaluating queries on probabilistic se complex events, and was intro- e review it here and discuss its limi- expressing q as a query plan, using , ×. Then modify each operator to nt attribute E in each intermediate , Π i , × i the modified operators. It is to introduce them in the functional defining the complex event ep(t) for ctively on the query plan p: = { ep(t) if c(t) is true ⊥ if c(t) is false = ∨ t ′ :Π ¯ A (t ′ )=t ep(t ′ ) (1) = ep(t) ∧ ep′^ (t ′ ) efinitions for σ i , Π i , × i follow easily: n copies the complex events from the he output tuples; Π i associates to a ex event e 1 ∨... ∨ e n obtained from A B C D E ‘m’ 1 1 ’p’ s 1 ∧ t 1 ‘n’ 1 1 ’p’ s 2 ∧ t 1 (a) S p ! i B=C T p D E ‘p’ (s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 ) (b) Π i D (S p ! i B=C T p ) D Rank ‘p ′ P r((s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 )) = 0. 54 (c) q rank (D p ) = P r(Π i D (S p ! i B=C T p )) Figure 5: Intensional Evaluation of Π D (S p ! B=C T p ) the complex events of all input tuples t 1 ,... , tn that project into t; and × i simply associates to a product tuple (t, t ′ ) the complex event e ∧ e ′ . Example 4. 1 Let us consider the database D p de- scribed in Figure 1. Consider the query plan, p = ΠD (S p !B=C T p ). Figure 5 shows the intensional evaluation of the query (we used the tuple names as atomic events). p i (D p ) contains a single tuple ′ p ′ with the event (s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 ). Thus, p i (D p ) denotes an intensional probabilistic relation. It can be shown that this is independent on the particular choice of plan p, and we denote q i (D p ) the value p i (D p ) for any plan p for q, and call it the in- tensional semantics 5 of q on the probabilistic database D p
. We prove now that it is equivalent to the possible
worlds semantics, q pwd (D p ). Theorem 4.2. The intensional semantics and the possible worlds semantics on probabilistic databases coincide for conjunctive queries. More precisely, pwd(q i (D p )) = q pwd (D p ) for every intensional prob- abilistic database D p and conjunctive query q. (All proofs in this paper are available in our techni- cal report [10].) Theorem 4.2 allows us to compute q rank (D p ), as follows. First compute q i (D p ), then compute the probability P r(e) for each complex event. Then q rank (D p ) = P r(q i (D p )). Example 4. 3 Fig. 5(c) shows p rank (D p ) for Ex. 4.1. P r((s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 )) was shown in Ex. 3.1. It is very impractical to use the intensional seman- tics to compute the rank probabilities, for two reasons. First, the event expressions in q i (D p ) can become very large. In the worst case the size of such an expres- sion can become of the same order of magnitude as the database. For instance, if a projection on a table
nting its probability. tion Problem This paper ad- oblem: given schema ¯ R p , Γ p , a D p and a query q over schema ilistic rankings q rank (D p ). eries with uncertain pred- deterministic database D and citly mentions some uncertain bles. We convert this problem ministic query q, obtained by predicates from q ≈ , on a prob- ined by associating a probabil- t based on how well t satisfies s in the query.
central problem, evaluating q, and a probabilistic database ition directly is infeasible, since er a large set of database in- ill first review the intensional describe our approach. iscussion first to conjunctive atively can be expressed as -join queries. This helps us bet- ry evaluation problem and its nsider more complex query ex- use either datalog notation for p in the select/project/product ery Evaluation ating queries on probabilistic mplex events, and was intro- ew it here and discuss its limi- essing q as a query plan, using Then modify each operator to ribute E in each intermediate i the modified operators. It is roduce them in the functional ing the complex event e p (t) for y on the query plan p: e p (t) if c(t) is true ⊥ if c(t) is false ∨ ′ :Π ¯ A (t ′ )=t ep(t ′ ) (1) ′ A B C D E ‘m’ 1 1 ’p’ s 1 ∧ t 1 ‘n’ 1 1 ’p’ s 2 ∧ t 1 (a) S p ! i B=C T p D E ‘p’ (s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 ) (b) Π i D (S p ! i B=C T p ) D Rank ‘p ′ P r((s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 )) = 0. 54 (c) q rank (D p ) = P r(Π i D (S p ! i B=C T p )) Figure 5: Intensional Evaluation of Π D (S p ! B=C T p ) the complex events of all input tuples t 1 ,... , t n that project into t; and × i simply associates to a product tuple (t, t ′ ) the complex event e ∧ e ′ . Example 4. 1 Let us consider the database D p de- scribed in Figure 1. Consider the query plan, p = Π D (S p ! B=C T p ). Figure 5 shows the intensional evaluation of the query (we used the tuple names as atomic events). p i (D p ) contains a single tuple ′ p ′ with the event (s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 ). Thus, p i (D p ) denotes an intensional probabilistic relation. It can be shown that this is independent on the particular choice of plan p, and we denote q i (D p ) the value p i (D p ) for any plan p for q, and call it the in- tensional semantics 5 of q on the probabilistic database D p
. We prove now that it is equivalent to the possible
worlds semantics, q pwd (D p ). Theorem 4.2. The intensional semantics and the possible worlds semantics on probabilistic databases coincide for conjunctive queries. More precisely, pwd(q i (D p )) = q pwd (D p ) for every intensional prob- abilistic database D p and conjunctive query q. (All proofs in this paper are available in our techni- cal report [10].) Theorem 4.2 allows us to compute q rank (D p ), as follows. First compute q i (D p ), then compute the probability P r(e) for each complex event. Then q rank (D p ) = P r(q i (D p )). Example 4. 3 Fig. 5(c) shows p rank (D p ) for Ex. 4.1. P r((s 1 ∧ t 1 ) ∨ (s 2 ∧ t 1 )) was shown in Ex. 3.1.
This would result in the correct probability. Can also see correlations. Evaluate the expression at the end (this can be #P-Hard) Can handles correlations (between tuples)
Intensional is too expensive
between tuples “Closed” Always correct (which means still #P-Hard in general) Can achieve the best of both worlds
“Ranking” is all thats needed