View
36
Download
1
Category
Tags:
Preview:
DESCRIPTION
Evaluation of Conditional Preference Queries. Fabíola S. Fernandes, Sandra de Amo. UNIVERSIDADE FEDERAL DE UBERLÂNDIA. PÓS-GRADUAÇÃO EM CIÊNCIA DA COMPUTAÇÃO. MOTIVATION. Movies ( T itle , G enre , Y ears , D irector , A ctor ). My preferences : - PowerPoint PPT Presentation
Citation preview
Evaluation of Conditional Evaluation of Conditional Preference QueriesPreference Queries
Fabíola S. Fernandes, Sandra de Amo
UNIVERSIDADE FEDERAL DE UBERLÂNDIA
PÓS-GRADUAÇÃO EMCIÊNCIA DA COMPUTAÇÃO
Page 2
MOTIVATION
UFU
Movies ( Title, Genre, Years, Director, Actor )
My preferences:
(1) I prefer those movies produced in the 90’s rather than
from 80’s, if both belongs to the same category (genre);
(2) For the movies produced in the 80’s I prefer dramas to
comedies;
(3) For Woody Allen’s films of the same genre and decade, I
prefer those staring the actress Charlotte Rampling than
those staring Mia Farrow.
Page 3
MOTIVATION
UFU
Queries:
Give the titles of the films which most fulfill my
wishes among those stored in the database,
provided they are not romance films.
Give the 4 films, among those stored in the
database, which most fulfill my wishes.
Movies ( Title, Genre, Years, Director, Actor )
Page 4
OUTLINE
UFU
The CPref-SQL Language
Related Work and Contributions
Evaluation of Preference Queries (cp-queries)
Top-K cp-queries in the RDBMS
Experimental Results
Conclusion and Further Work
Page 5
THE CPref-SQL LANGUAGE
UFU
An extension of SQL able to express conditional
preference queries
The queries incorporate the usual hard constraints
(WHERE) as well as soft constraints (preference rules)
Goals:
Express preferences over a database
Filter the answer to queries according to user
preferences
Page 6
THE CPref-SQL LANGUAGE
UFU
Express preferences over a database as follows:
CREATE PREFERENCES MyPrefs FROM Movies AS
Y=90 > Y=80 [T,D,A] AND
IF D=Woody Allen THEN A=Charlotte Rampling > A=Mia Farrow
[T] AND
IF G=comedy and Y=80 THEN D=Joel Coen > D=Woody Allen
[T,A] AND
IF Y=80 THEN G=drama > G=comedy [T]
Page 7
THE CPref-SQL LANGUAGE
UFU
Filter the answers to queries according to user
preferences
SELECT titleFROM movies WHERE genre <> ‘romance’ACCORDING TO PREFERENCES MyPrefs, 4
Page 8
OUTLINE
UFU
The CPref-SQL Language
Related Work and Contributions
Evaluation of Preference Queries (cp-queries)
Top-K cp-queries in the RDBMS
Experimental Results
Conclusion and Further Work
Page 9
RELATED WORK AND CONTRIBUTIONS
UFU
Topic State of the Art
Modeling and reasoning of preferences
CP-NetTCP-NetConditional Preference Formulas
SQL extensionsPreference SQLCPref-SQL
Preference OperatorsSkylineWinnowSelect-Best
Algorithms for evaluation of preference queries
BNL – skyline queriesSFSBNL+, BNL++BNL*, …
Top-K queriesTop N, Top K – rankingTop K dominating
Implementation On-top, Centrist, Built-in
Page 10
RELATED WORK AND CONTRIBUTIONS
UFU
Topic State of the Art
Modeling and reasoning of preferences
CP-NetTCP-NetConditional Preference Formulas
SQL extensionsPreference SQLCPref-SQL
Preference OperatorsSkylineWinnowSelect-Best
Algorithms for evaluation of preference queries
BNL – skyline queriesSFSBNL+, BNL++BNL*, …
Top-K queriesTop N, Top K – rankingTop K dominating
Implementation On-top, Centrist, Built-in
Proposal
Conditional Preference Formulas
CPref-SQL
SelectK-Best
BNL** e R-BNL**
Top-K cp-queries
Built-in
Page 11
CONTRIBUTIONS
UFU
Top-K cp-queries
Algorithms BNL** and R-BNL** for evaluating the
Select-Best and SelectK-Best operators
Implementation in the core of the RDBMS PostgreSQL
Experiments comparing the built-in approach with the
translation into standard SQL
Page 12
OUTLINE
UFU
The CPref-SQL Language
Related Work and Contributions
Evaluation of Preference Queries (cp-
queries)
Top-K cp-queries in the RDBMS
Experimental Results
Conclusion and Further Work
Page 13
THE PREFERENCE MODEL
UFU
R1: (Y = 90) > (Y = 80) [{T,D,A}],
R2: (D = wa) (A = cr) > (A = mf) [{T}],
R3: (G = c) ^ (Y = 80) (D = jc) > (D = wa)
[{T,A}],
R4: (Y = 80) (G = d) > (G = c) [{T}].
Title GenreYears
Director Actor
t1 Titanic drama 90James
CameronBill Paxton
t2Stardust
Memoriesdrama 80 Woody Allen
Charlotte Rampling
t3 New York Stories drama 80 Woody Allen Mia Farrow
t4A Midsummer
Night's Sex Comedy
comedy
80 Woody Allen Mia Farrow
t5 Crimewavecomed
y80 Joel Coen Louise Lasser
t6 Avatar action 00James
CameronZoe Saldana
t1
t2
t3
t4
t5
t6
Page 14
THE PREFERENCE MODEL
UFU
R1: (Y = 90) > (Y = 80) [{T,D,A}],
R2: (D = wa) (A = cr) > (A = mf) [{T}],
R3: (G = c) ^ (Y = 80) (D = jc) > (D = wa)
[{T,A}],
R4: (Y = 80) (G = d) > (G = c) [{T}].
Title GenreYears
Director Actor
t1 Titanic drama 90James
CameronBill Paxton
t2Stardust Memories
drama 80 Woody AllenCharlotte Rampling
t3New York Stories
drama 80 Woody Allen Mia Farrow
t4A Midsummer
Night's Sex Comedy
comedy
80 Woody Allen Mia Farrow
t5 Crimewavecomed
y80 Joel Coen Louise Lasser
t6 Avatar action 00James
CameronZoe Saldana
t1
t2
t3
t4
t5
t6
R2
Page 15
THE PREFERENCE MODEL
UFU
R1: (Y = 90) > (Y = 80) [{T,D,A}],
R2: (D = wa) (A = cr) > (A = mf) [{T}],
R3: (G = c) ^ (Y = 80) (D = jc) > (D = wa)
[{T,A}],
R4: (Y = 80) (G = d) > (G = c) [{T}].
Title GenreYears
Director Actor
t1 Titanic drama 90James
CameronBill Paxton
t2Stardust
Memoriesdrama 80 Woody Allen
Charlotte Rampling
t3New York Stories
drama 80 Woody Allen Mia Farrow
t4A Midsummer Night's Sex
Comedy
comedy
80 Woody Allen Mia Farrow
t5 Crimewave comedy 80 Joel Coen Louise Lasser
t6 Avatar action 00James
CameronZoe Saldana
t1
t2
t3
t4
t5
t6
R2
R4
Page 16
THE PREFERENCE MODEL
UFU
R1: (Y = 90) > (Y = 80) [{T,D,A}],
R2: (D = wa) (A = cr) > (A = mf) [{T}],
R3: (G = c) ^ (Y = 80) (D = jc) > (D = wa)
[{T,A}],
R4: (Y = 80) (G = d) > (G = c) [{T}].
Title GenreYears
Director Actor
t1 Titanic drama 90James
CameronBill Paxton
t2Stardust
Memoriesdrama 80 Woody Allen
Charlotte Rampling
t3 New York Stories drama 80 Woody Allen Mia Farrow
t4A Midsummer
Night's Sex Comedy
comedy
80 Woody Allen Mia Farrow
t5 Crimewavecomed
y80 Joel Coen Louise Lasser
t6 Avatar action 00James
CameronZoe Saldana
t1
t2
t3
t4
t5
t6
R2
R4
Page 17
THE PREFERENCE MODEL
UFU
R1: (Y = 90) > (Y = 80) [{T,D,A}],
R2: (D = wa) (A = cr) > (A = mf) [{T}],
R3: (G = c) ^ (Y = 80) (D = jc) > (D = wa)
[{T,A}],
R4: (Y = 80) (G = d) > (G = c) [{T}].
Title GenreYears
Director Actor
t1 Titanic drama 90James
CameronBill Paxton
t2Stardust
Memoriesdrama 80 Woody Allen
Charlotte Rampling
t3 New York Stories drama 80 Woody Allen Mia Farrow
t4A Midsummer
Night's Sex Comedy
comedy
80 Woody Allen Mia Farrow
t5 Crimewavecomed
y80 Joel Coen Louise Lasser
t6 Avatar action 00James
CameronZoe Saldana
t1
t2
t3
t4
t5
t6
R2
R4
Page 18
THE PREFERENCE MODEL
UFU
R1: (Y = 90) > (Y = 80) [{T,D,A}],
R2: (D = wa) (A = cr) > (A = mf) [{T}],
R3: (G = c) ^ (Y = 80) (D = jc) > (D = wa)
[{T,A}],
R4: (Y = 80) (G = d) > (G = c) [{T}].
Title GenreYears
Director Actor
t1 Titanic drama 90James
CameronBill Paxton
t2Stardust
Memoriesdrama 80 Woody Allen
Charlotte Rampling
t3 New York Stories drama 80 Woody Allen Mia Farrow
t4A Midsummer
Night's Sex Comedy
comedy
80 Woody Allen Mia Farrow
t5 Crimewavecomed
y80 Joel Coen Louise Lasser
t6 Avatar action 00James
CameronZoe Saldana
t1
t2
t3
t4
t5
t6
R2
R4
Page 19
CONSISTENCY TEST [Wilson 2004]
UFU
R1: (Y = 90) > (Y = 80) [{T,D,A}],
R2: (D = wa) (A = cr) > (A = mf) [{T}],
R3: (G = c) ^ (Y = 80) (D = jc) > (D = wa)
[{T,A}],
R4: (Y = 80) (G = d) > (G = c) [{T}],
R5: (G = c) (Y=80) > (Y = 90) [{T}]
When a cp-theory is consistent?
Dependency Graph Local Consistency
Y
GD
A
T
Years
90 80
(x, c, 80, y, z) (x, c, 90, y, z) ?
Page 20
CPref-SQL ALGEBRA OPERATORS
R
Tuples that do not have any other tuple over them in the preference hierarchy
K
R
K tuples with the less number of tuples above them in the preference
hierarchy
Select-Best
SelectK-Best
UFU
Page 21 UFU
π
SelectBest / SelectK-Best
|X|
R1 Rn...
SELECT < attribute-list >
FROM < tables >
WHERE < where-conditions (hard
conditions) >
ACCORDING TO PREFERENCES
< preference (soft conditions) >
CPref-SQL ALGEBRA OPERATORS
Page 22
ALGORITHMS BNL** E R-BNL**
UFU
SelectBest
BNL**
SelectK-Best
R-BNL**
Follows the lines of the Blocked Nested Loop (BNL)
algorithm (BORZSONYI et al. ICDE 2001)
Uses the structure of a Datalog program to compare
tuples
Page 23
ALGORITHMS BNL** E R-BNL**
UFU
Dominance Test
Input: tuples t1, t2
Output: t1 > t2 or t2 > t1 or t1 ~ t2 (incomparable)
Method
1. Projection
2. CP-Theory = Datalog program
Test t1 > t2 : datalog goal
Page 24 UFU
Dominance Test: t1 > t2? t2 > t1? t1 ~ t2?
CP-theory
1. A = a1 -> C = c1 > C
= c2
2. B = b1 -> C = c2 > C
= c3
R (A, B, C, D)
dom(A) = {a1, a2, a3}dom(B) = {b1, b2}dom(C) = {c1, c2, c3}dom(D) = {d1, d2}
t1, t2 Are comparable?
(a1,b1,c1,d1) and (a1,b1,c1,d2) No
(a2,b1,c1,d1) and (a1,b1,c3,d1) No
(a2,b2,c2,d1) and (a2,b2,c3,d1) Yes
(a1,b1,c2,d1) and (a1,b1,c3,d1) Yes
(a2,b2,c2) and (a2,b2,c3)
(a1,b1,c2) and (a1,b1,c3)
Projections
1. Projection
ALGORITHMS BNL** E R-BNL**
Page 25
ALGORITHMS BNL** E R-BNL**
UFU
Dominance Test: t1 > t2? t2 > t1? t1 ~ t2?
2. CP-theory = Datalog Program
Converts the preference rules in a Datalog program P
Each dominance test of 2 comparable tuples is a goal for P
Finds the solution (goal) using SLD resolution method
Page 26
ALGORITHMS BNL** E R-BNL**
UFU
Dominance Test: t1 > t2? t2 > t1? t1 ~ t2?
CP-Theory
1. A = a1 -> C = c1 > C
= c2
2. B = b1 -> C = c2 > C
= c3Datalog Program
1. pref(x1, y1, z1, x2, y2, z2 ) <- x1 = a1, x2 = a1, y1 = y2, z1 = c1 ,
z2 = c2
2. pref(x1, y1, z1, x2, y2, z2 ) <- x1 = x2, y1 = b1, y2, = b1, z1 = c2 ,
z2 = c3
3. dom( x1, y1, z1, x2, y2, z2 ) <- pref( x1, y1, z1, x2, y2, z2 )
4. dom( x1, y1, z1, x2, y2, z2 ) <- pref( x1, y1, z1, x3, y3, z3 ),
dom( x3, y3, z3, x2, y2, z2 )
Page 27
ALGORITHMS BNL** E R-BNL**
UFU
Dominance Test: t1 > t2? t2 > t1? t1 ~ t2?
2. CP-theory = Datalog Program
Test
(a1, b1, c1) > (a1, b1, c2)
Goal
dom( a1, b1, c1, a1, b1, c2 )
Page 28
ALGORITHM BNL**
UFU
Procedure MostPref(r)
1. clear the in-memory page W and the temporary table F
2. make r the input
3. repeat the following until the input is empty
4. forfor every tuple t in the input
5. ifif t is dominated by a tuple in W
6. thenthen ignore t
7. ifif t dominates some tuples in W
8. thenthen eliminate the dominated tuples and insert t into W
9. ifif t is incomparable with all tuples in W
10. thenthen insert t into W if there is room, otherwise add t to F
11. insert in S the tuples of W which were added there when F was empty
12. make F the input, clear the temporary table
13. return S
Page 29
ALGORITHM R-BNL**
UFU
t1
t2
t3
t4
t5
t6
Output S
t1[]
t2[t1]
t3[t1,t2]
t4[t1,t2,t3,t5]t5[]
t6[]
l(t) = 0 t’ r| t’ > t max { l(t’) | t’ > t } + 1 otherwise
0 0
01
2
3
SelectK-Best ( 4, R ) = { t1, t5, t6, t2}
Page 30
ALGORITHM R-BNL**
UFU
Procedure topK(r)
1. clear the in-memory page W and the temporary table F
2. make r the input
3. repeat the following until the input is empty
4.4. forfor every tuple t in the input
5. for every tuple t’ in W
6.6. ifif t is dominated by t’
7.7. thenthen add t’ into MorePref(t)
8.8. ifif t dominates t’
9.9. thenthen add t into MorePref(t’)
10. insert t into W if there is room, otherwise add t to F
11. insert in S the tuples of W which were added there when F was
empty
12. make F the input, clear the temporary table
13. Return S
Page 31
OUTLINE
UFU
The CPref-SQL Language
Related Work and Contributions
Evaluation of Preference Queries (cp-queries)
Top-K cp-queries in the RDBMS
Experimental Results
Conclusion and Further Work
Page 32
TOP-K CP-QUERIES IN THE RDBMS
UFU
Extension for PostgreSQL 8.4
Linux Operational System
C Language
Directly implemented in the Postgres back-end: built-in
approach
Page 33 UFU
Postgresback-end
CREATE PREFERENCES
TOP-K CP-QUERIES IN THE RDBMS
Page 34 UFU
Postgresback-end
ACCORDING TO
PREFERENCES
TOP-K CP-QUERIES IN THE RDBMS
Page 35 UFU
TOP-K CP-QUERIES IN THE RDBMS
Page 36
OUTLINE
UFU
The CPref-SQL Language
Related Work and Contributions
Evaluation of Preference Queries (cp-queries)
Top-K cp-queries in the RDBMS
Experimental Results
Conclusion and Further Work
Page 37
EXPERIMENTAL RESULTS
UFU
Benchmark TPC-H (http://www.tpc.org/tpch/)
Synthetic database
Suite with 22 SQL queries
Queries adaptation:
insertion of the preference clause
removal of aggregate functions (group by, having, …)
changes on the terms of the WHERE clause
Performance and scalability evaluations of CPref-
SQL queries and their translations to SQL
All CPref-SQL query can be translated into SQL queries
with recursion
Page 38
EXPERIMENTAL RESULTS
UFU
Conversion CPref-SQL <-> SQL
CREATE OR REPLACE VIEW Rules (title,genre,years,director,actor,tit,gen,yea,dir,act) AS
(SELECT * FROM movies M, movies M1 WHERE M.genre = ‘drama' AND M1.genre = ‘musical'
AND M.director = M1.director AND M.years = M1.years)
UNION (SELECT * FROM movies M, movies M1 WHERE M.years = 90 AND M1.years = 80 and M.genre
= M1.genre) UNION (SELECT * FROM movies M, movies M1 WHERE M.years = 80 and M1.years = 80 and M.genre =
‘drama’ and M1.genre = ‘comedy’ and M.director = M1.director and M.actor = M1.actor);
CREATE PREFERENCES mypref
FROM movies AS
genre = ‘drama > genre = ‘musical’ [1,5]
AND
years = 90 > years = 80 [1,4,5]
AND
IF years = 80 THEN genre = ‘drama’ > genre = ‘comedy’ [1]
Page 39
EXPERIMENTAL RESULTS
UFU
Conversion CPref-SQL <-> SQL WITH RECURSIVE Recursion ( tit, gen, yea, dir, act, title, genre, years, director, actor ) AS (
( SELECT * FROM Rules )UNION
( SELECT M.title, M.genre, M.years, M.director, M.actor, R.title, R.genre, R.years, R.director, R.actor
FROM Rules M, Recursion R WHERE M.tit = R.tit AND
M.gen = R.gen AND M.yea = R.yea M.dir = R.dir AND M.act = R.act ) )
SELECT *
FROM movies
WHERE genre <> ‘romance’
ACCORDING TO PREFERENCES
mypref
SELECT *
FROM movies
WHERE genre <> ‘romance’
EXCEPT
SELECT R.title, R.genre, R.years, R.director, R.actor
FROM Recursion R;
Page 40
EXPERIMENTAL RESULTS
UFU
Performance
Page 41
EXPERIMENTAL RESULTS
UFU
Scalability
Page 42
OUTLINE
UFU
The CPref-SQL Language
Related Work and Contributions
Evaluation of Preference Queries (cp-queries)
Top-K cp-queries in the RDBMS
Experimental Results
Conclusion and Further Work
Page 43
CONCLUSION AND FURTHER WORK
UFU
Development of algorithms under the approach on-top
Supporting to other built-in predicates (>, <, >=,…)
Ongoing research:
Top-K cp-queries
Algorithms BNL** e R-BNL**
Implementation in the core of the PostgreSQL
Incorporating aggregate operations in the CPref-SQL
block
Optimization of the execution plan – rules rewrite
Future research:
Evaluation of Conditional Evaluation of Conditional Preference QueriesPreference Queries
UNIVERSIDADE FEDERAL DE UBERLÂNDIA
PÓS-GRADUAÇÃO EMCIÊNCIA DA COMPUTAÇÃO
!! FIM !!
fabfernandes@comp.ufu.br, deamo@ufu.br
Fabíola S. Fernandes, Sandra de Amo
Page 45
ALGORITHM BNL**
UFU
Block of Pages
Buffer
Output page
Input Table
Temporary table F
The Preferred tuples = query
answer
Window W
Page 46
ALGORITHM BNL**
UFU
t1
t2
t3
t4
t5
t6
INPUT Output S
Buffer W
t1
t2
t3
t4
t5
t6
Temporary table F
t1
t5
t6
t6
Page 47
ALGORITHM R-BNL**
UFU
Block of Pages
Buffer
Output page
Input Table
Temporary table F
Window W
All tuples with their respective MorePref lists
Page 48
ALGORITHM R-BNL**
UFU
t1
t2
t3
t4
t5
t6
INPUT Output S
Buffer W
t1[]
t2[]
t3[]
t4[]
t5[]
t6[]
Temporary table F
t2[t1]
t3[t1,t2]
t4[t1,t2]
Page 49
ALGORITHM R-BNL**
UFU
t1
t2
t3
t4
t5
t6
INPUT Output S
Buffer W
t1[]
Temporary table F
t2[t1]
t3[t1,t2]
t5[]
t6[]
t4[t1,t2]
Page 50
ALGORITHM R-BNL**
UFU
t1
t2
t3
t4
t5
t6
Output S
t1[]
t2[t1]
t3[t1,t2]
t4[t1,t2,t3,t5]t5[]
t6[]
l(t) = 0 t’ r| t’ > t max { l(t’) | t’ > t } + 1 otherwise
0 0
01
2
3
SelectK-Best ( 4, R ) = { t1, t5, t6, t2}
Page 51 UFU
Create Preferences
Catalog structure:
Each column is an attribute of the relation
movies
Each row represents a ruleID
Ruletitle
genreyear
sdirector actor
1 NIL * 90|80 NIL NIL
2 NIL * * Woody Allen Charlotte Rampling|Mia Ferrow
3 NIL comedy 80 Joel Coen|Woody Allen NIL
4 NIL drama|comedy 80 * *
TOP-K CP-QUERIES IN THE RDBMS
Page 52 UFU
Create Preferences
TOP-K CP-QUERIES IN THE RDBMS
Page 53 UFU
Insertion of the operators in the query processor
TOP-K CP-QUERIES IN THE RDBMS
Recommended