Download presentation

Presentation is loading. Please wait.

Published byEliseo Eckersley Modified about 1 year ago

1
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

2
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.

3
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 )

4
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

5
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

6
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]

7
Page 7 THE CPref-SQL LANGUAGE UFU Filter the answers to queries according to user preferences SELECT title FROM movies WHERE genre <> ‘romance’ ACCORDING TO PREFERENCES MyPrefs, 4

8
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

9
Page 9 RELATED WORK AND CONTRIBUTIONS UFU TopicState of the Art Modeling and reasoning of preferences CP-Net TCP-Net Conditional Preference Formulas SQL extensions Preference SQL CPref-SQL Preference Operators Skyline Winnow Select-Best Algorithms for evaluation of preference queries BNL – skyline queries SFS BNL+, BNL++ BNL*, … Top-K queries Top N, Top K – ranking Top K dominating Implementation On-top, Centrist, Built-in

10
Page 10 RELATED WORK AND CONTRIBUTIONS UFU TopicState of the Art Modeling and reasoning of preferences CP-Net TCP-Net Conditional Preference Formulas SQL extensions Preference SQL CPref-SQL Preference Operators Skyline Winnow Select-Best Algorithms for evaluation of preference queries BNL – skyline queries SFS BNL+, BNL++ BNL*, … Top-K queries Top N, Top K – ranking Top 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

11
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

12
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

13
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}]. TitleGenreYearsDirectorActor t1Titanicdrama90James CameronBill Paxton t2Stardust Memoriesdrama80Woody AllenCharlotte Rampling t3New York Storiesdrama80Woody AllenMia Farrow t4 A Midsummer Night's Sex Comedy comedy80Woody AllenMia Farrow t5Crimewavecomedy80Joel CoenLouise Lasser t6Avataraction00James CameronZoe Saldana t1 t2 t3 t4 t5 t6

14
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}]. TitleGenreYearsDirectorActor t1Titanicdrama90James CameronBill Paxton t2 Stardust Memories drama80Woody Allen Charlotte Rampling t3New York Storiesdrama80Woody AllenMia Farrow t4 A Midsummer Night's Sex Comedy comedy80Woody AllenMia Farrow t5Crimewavecomedy80Joel CoenLouise Lasser t6Avataraction00James CameronZoe Saldana t1 t2 t3 t4 t5 t6 R2

15
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}]. TitleGenreYearsDirectorActor t1Titanicdrama90James CameronBill Paxton t2Stardust Memoriesdrama80Woody AllenCharlotte Rampling t3New York Storiesdrama80Woody AllenMia Farrow t4 A Midsummer Night's Sex Comedy comedy80Woody AllenMia Farrow t5Crimewavecomedy80Joel CoenLouise Lasser t6Avataraction00James CameronZoe Saldana t1 t2 t3 t4 t5 t6 R2 R4

16
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}]. TitleGenreYearsDirectorActor t1Titanicdrama90James CameronBill Paxton t2Stardust Memoriesdrama80Woody AllenCharlotte Rampling t3New York Storiesdrama80Woody AllenMia Farrow t4 A Midsummer Night's Sex Comedy comedy80Woody AllenMia Farrow t5Crimewavecomedy80Joel CoenLouise Lasser t6Avataraction00James CameronZoe Saldana t1 t2 t3 t4 t5 t6 R2 R4

17
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}]. TitleGenreYearsDirectorActor t1Titanicdrama90James CameronBill Paxton t2Stardust Memoriesdrama80Woody AllenCharlotte Rampling t3New York Storiesdrama80Woody AllenMia Farrow t4 A Midsummer Night's Sex Comedy comedy80Woody AllenMia Farrow t5Crimewavecomedy80Joel CoenLouise Lasser t6Avataraction00James CameronZoe Saldana t1 t2 t3 t4 t5 t6 R2 R4

18
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}]. TitleGenreYearsDirectorActor t1Titanicdrama90James CameronBill Paxton t2Stardust Memoriesdrama80Woody AllenCharlotte Rampling t3New York Storiesdrama80Woody AllenMia Farrow t4 A Midsummer Night's Sex Comedy comedy80Woody AllenMia Farrow t5Crimewavecomedy80Joel CoenLouise Lasser t6Avataraction00James CameronZoe Saldana t1 t2 t3 t4 t5 t6 R2 R4

19
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 9080 (x, c, 80, y, z)(x, c, 90, y, z)?

20
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

21
Page 21 UFU π SelectBest / SelectK-Best |X| R1R1 RnRn... SELECT FROM WHERE ACCORDING TO PREFERENCES CPref-SQL ALGEBRA OPERATORS

22
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

23
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

24
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, t2Are 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**

25
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

26
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 = c3 Datalog 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 )

27
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 )

28
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 for 4. for every tuple t in the input if 5. if t is dominated by a tuple in W then 6. then ignore t if 7. if t dominates some tuples in W then 8. then eliminate the dominated tuples and insert t into W if 9. if t is incomparable with all tuples in W then 10. then 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

29
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 } + 1otherwise 00 0 1 2 3 SelectK-Best ( 4, R ) = { t1, t5, t6, t2}

30
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. for 4. for every tuple t in the input 5. for every tuple t’ in W 6. if 6. if t is dominated by t’ 7. then 7. then add t’ into MorePref(t) 8. if 8. if t dominates t’ 9. then 9. then 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

31
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

32
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

33
Page 33 UFU Postgres back-end CREATE PREFERENCES TOP-K CP-QUERIES IN THE RDBMS

34
Page 34 UFU Postgres back-end ACCORDING TO PREFERENCES TOP-K CP-QUERIES IN THE RDBMS

35
Page 35 UFU TOP-K CP-QUERIES IN THE RDBMS

36
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

37
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

38
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]

39
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;

40
Page 40 EXPERIMENTAL RESULTS UFU Performance

41
Page 41 EXPERIMENTAL RESULTS UFU Scalability

42
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

43
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:

44
Evaluation of Conditional Preference Queries UNIVERSIDADE FEDERAL DE UBERLÂNDIA PÓS-GRADUAÇÃO EM CIÊNCIA DA COMPUTAÇÃO !! FIM !! fabfernandes@comp.ufu.br, deamo@ufu.br Fabíola S. Fernandes, Sandra de Amo

45
Page 45 ALGORITHM BNL** UFU Block of Pages Buffer Output page Input Table Temporary table F The Preferred tuples = query answer Window W

46
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

47
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

48
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]

49
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]

50
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 } + 1otherwise 00 0 1 2 3 SelectK-Best ( 4, R ) = { t1, t5, t6, t2}

51
Page 51 UFU Create Preferences Catalog structure: Each column is an attribute of the relation movies Each row represents a rule ID Rule titlegenreyearsdirectoractor 1NIL*90|80NIL 2 **Woody Allen Charlotte Rampling|Mia Ferrow 3NILcomedy80 Joel Coen|Woody Allen NIL 4 drama|comedy80** TOP-K CP-QUERIES IN THE RDBMS

52
Page 52 UFU Create Preferences TOP-K CP-QUERIES IN THE RDBMS

53
Page 53 UFU Insertion of the operators in the query processor TOP-K CP-QUERIES IN THE RDBMS

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google