a survey of deductive databases
play

A Survey of Deductive Databases Raghu Ramakrishnan and Jeffrey D. - PowerPoint PPT Presentation

A Survey of Deductive Databases Raghu Ramakrishnan and Jeffrey D. Ullman CS 848, Fall 2016 University of Waterloo Presented by: Siddhartha Sahu Overview Relational Databases Deductive Databases Datalog Example Queries


  1. A Survey of Deductive Databases Raghu Ramakrishnan and Jeffrey D. Ullman CS 848, Fall 2016 University of Waterloo Presented by: Siddhartha Sahu

  2. Overview ● Relational Databases ● Deductive Databases ● Datalog ● Example Queries ● Query Execution ● Conclusion and Discussion

  3. Relational Databases

  4. Relational Databases Predominant model for data storage and processing

  5. Relational Databases Predominant model for data storage and processing Declarative language: focus on what rather than how

  6. Relational Databases c d f a e b

  7. Relational Databases c edges id_from id_to d f a b INSERT INTO edges (...) a b d b e e d c b f e

  8. Relational Databases c edges id_from id_to d f a b INSERT INTO edges (...) a b d b e e d c b f e Q: List vertices that vertex ‘b’ have an outgoing edge to.

  9. Relational Databases c edges id_from id_to d f a b INSERT INTO edges (...) a b d b e e d c b f e Q: List vertices that vertex ‘b’ have an outgoing edge to. A: SELECT id_to from edges WHERE id_from = ‘b’

  10. Relational Databases c edges id_from id_to d f a b INSERT INTO edges (...) a b d b e e d c b f e Q: List all vertex pairs (x,y), such that y is reachable from x. A: ?

  11. Deductive Databases

  12. Deductive Databases Support a superset of relational algebra. ● Supports all queries from relational algebra. Logic Programs ● Supports recursions. Relational Algebra

  13. Deductive Databases Support a superset of relational algebra. ● Supports all queries from relational algebra. Logic Programs ● Supports recursions. Datalog: subset of Prolog, a logic programming language ● Database centric requirements ● Emphasis on completeness and termination ● Relational Queries on data stored on secondary storage Algebra

  14. Deductive Databases Support a superset of relational algebra. ● Supports all queries from relational algebra. Logic Programs ● Supports recursions. Datalog: subset of Prolog, a logic programming language ● Database centric requirements ● Emphasis on completeness and termination ● Relational Queries on data stored on secondary storage Algebra A database of facts. A set of rules for deriving new facts from existing facts.

  15. Datalog: Terminology Datalog

  16. Datalog: Terminology edge(a,b). Facts Datalog

  17. Datalog: Terminology edge(a,b). Facts Datalog connected(X,Y) :- edge(X,Y). Rules connected(X,Y) :- edge(X,Z), connected(Z,Y).

  18. Datalog: Terminology edge(a,b). Facts Datalog connected(X,Y) :- edge(X,Y). Rules connected(X,Y) :- edge(X,Z), connected(Z,Y). Implication/Clause: A 0 :- A 1 , A 2 , ..., A k where A 0 is true if A 1 and A 2 … and A k are true. k = 0: fact; k > 0: rule

  19. Datalog: Terminology edge(a,b). Facts constant symbol terms logical variable Datalog head body connected(X,Y) :- edge(X,Y). Rules connected(X,Y) :- edge(X,Z), connected(Z,Y). predicate predicate Implication/Clause: A 0 :- A 1 , A 2 , ..., A k where A 0 is true if A 1 and A 2 … and A k are true. k = 0: fact; k > 0: rule

  20. Datalog: Terminology EDB edge(a,b). Facts constant symbol terms logical variable Datalog head body connected(X,Y) :- edge(X,Y). Rules connected(X,Y) :- edge(X,Z), connected(Z,Y). IDB predicate predicate Implication/Clause: A 0 :- A 1 , A 2 , ..., A k where A 0 is true if A 1 and A 2 … and A k are true. k = 0: fact; k > 0: rule

  21. Datalog: Examples users accounts uid uid name account_type age amount

  22. Datalog: Examples users accounts uid uid name account_type age amount users(42, ‘Jane Doe’, 26). accounts(42, ‘savings’, 5692.23)

  23. Datalog: Examples users accounts uid uid Selection name account_type Q: List all users with age > 23. age amount users(42, ‘Jane Doe’, 26). accounts(42, ‘savings’, 5692.23)

  24. Datalog: Examples users accounts uid uid Selection name account_type Q: List all users with age > 23. age amount users(42, ‘Jane Doe’, 26). accounts(42, ‘savings’, 5692.23) Relational Algebra: σ age > 23 (users) SQL: SELECT * FROM users WHERE age > 23;

  25. Datalog: Examples users accounts uid uid Selection name account_type Q: List all users with age > 23. age amount users(42, ‘Jane Doe’, 26). accounts(42, ‘savings’, 5692.23) Relational Algebra: σ age > 23 (users) SQL: SELECT * FROM users WHERE age > 23; Datalog: S( Uid , Name, Age) :- users( Uid , Name, Age), Age > 23.

  26. Datalog: Examples users accounts uid uid Projection name account_type Q: List name of users with age > 23. age amount users(42, ‘Jane Doe’, 26). accounts(42, ‘savings’, 5692.23)

  27. Datalog: Examples users accounts uid uid Projection name account_type Q: List name of users with age > 23. age amount users(42, ‘Jane Doe’, 26). accounts(42, ‘savings’, 5692.23) Relational Algebra: π name (σ age > 23 (users)) SQL: SELECT name FROM users WHERE age > 23;

  28. Datalog: Examples users accounts uid uid Projection name account_type Q: List name of users with age > 23. age amount users(42, ‘Jane Doe’, 26). accounts(42, ‘savings’, 5692.23) Relational Algebra: π name (σ age > 23 (users)) SQL: SELECT name FROM users WHERE age > 23; Datalog: P( Name ) :- users( Uid , Name, Age), Age > 23.

  29. Datalog: Examples users accounts uid uid Join name account_type Q: List name, amount of users with age > 23. age amount users(42, ‘Jane Doe’, 26). accounts(42, ‘savings’, 5692.23)

  30. Datalog: Examples users accounts uid uid Join name account_type Q: List name, amount of users with age > 23. age amount users(42, ‘Jane Doe’, 26). accounts(42, ‘savings’, 5692.23) Relational Algebra: π name,amount (σ age > 23 (users ⨝ uid accounts)) SQL: SELECT name,amount FROM users,accounts WHERE users.uid = accounts.uid AND age > 23;

  31. Datalog: Examples users accounts uid uid Join name account_type Q: List name, amount of users with age > 23. age amount users(42, ‘Jane Doe’, 26). accounts(42, ‘savings’, 5692.23) Relational Algebra: π name,amount (σ age > 23 (users ⨝ uid accounts)) SQL: SELECT name,amount FROM users,accounts WHERE users.uid = accounts.uid AND age > 23; Datalog: J( Name,Amount ) :- users(Uid, Name, Age), accounts(Uid, Account_type, Amount), Age > 23.

  32. Datalog: Examples c d f a e b

  33. Datalog: Examples c edge(a,b). edge(b,d). d f edge(b,e). edge(d,c). edge(f,e). a Datalog e connected(X,Y) :- edge(X,Y). connected(X,Y) :- edge(X,Z), connected(Z,Y). b

  34. Datalog: Examples c edge(a,b). edge(b,d). d f edge(b,e). edge(d,c). edge(f,e). a Datalog e connected(X,Y) :- edge(X,Y). connected(X,Y) :- edge(X,Z), connected(Z,Y). b Q: List vertices that vertex ‘b’ have an outgoing edge to.

  35. Datalog: Examples c edge(a,b). edge(b,d). d f edge(b,e). edge(d,c). edge(f,e). a Datalog e connected(X,Y) :- edge(X,Y). connected(X,Y) :- edge(X,Z), connected(Z,Y). b Q: List vertices that vertex ‘b’ have an outgoing edge to. A: query(X) :- edge(b,X).

  36. Datalog: Examples c edge(a,b). edge(b,d). d f edge(b,e). edge(d,c). edge(f,e). a Datalog e connected(X,Y) :- edge(X,Y). connected(X,Y) :- edge(X,Z), connected(Z,Y). b Q: List all vertex pairs (x,y), such that y is reachable from x.

  37. Datalog: Examples c edge(a,b). edge(b,d). d f edge(b,e). edge(d,c). edge(f,e). a Datalog e connected(X,Y) :- edge(X,Y). connected(X,Y) :- edge(X,Z), connected(Z,Y). b Q: List all vertex pairs (x,y), such that y is reachable from x. A: query(X,Y) :- connected(X,Y).

  38. Query Evaluation: Naïve algorithm

  39. Query Evaluation: Naïve algorithm http://www.cs.toronto.edu/~drosu/csc343-l7-handout6.pdf, http://courses.cs.washington.edu/courses/csep544/14wi/video/archive/html5/csep544_14wi_8/slide775.jpg

  40. Query Evaluation: Naïve algorithm 1. Begin by assuming all IDB relations are empty. http://www.cs.toronto.edu/~drosu/csc343-l7-handout6.pdf, http://courses.cs.washington.edu/courses/csep544/14wi/video/archive/html5/csep544_14wi_8/slide775.jpg

  41. Query Evaluation: Naïve algorithm 1. Begin by assuming all IDB relations are empty. 2. Repeatedly evaluate the rules using the EDB and the previous IDB to get a new IDB. http://www.cs.toronto.edu/~drosu/csc343-l7-handout6.pdf, http://courses.cs.washington.edu/courses/csep544/14wi/video/archive/html5/csep544_14wi_8/slide775.jpg

  42. Query Evaluation: Naïve algorithm 1. Begin by assuming all IDB relations are empty. 2. Repeatedly evaluate the rules using the EDB and the previous IDB to get a new IDB. 3. End when there is no change to the IDB. http://www.cs.toronto.edu/~drosu/csc343-l7-handout6.pdf, http://courses.cs.washington.edu/courses/csep544/14wi/video/archive/html5/csep544_14wi_8/slide775.jpg

  43. Query Evaluation: Naïve algorithm connected(X,Y) :- edge(X,Y). connected(X,Y) :- edge(X,Z), connected(Z,Y). c f d a e b connected(X,Y).

  44. Query Evaluation: Naïve algorithm connected(X,Y) :- edge(X,Y). edges connected(X,Y) :- edge(X,Z), connected(Z,Y). c a b b d f d d c a b e e f e b connected(X,Y). http://courses.cs.washington.edu/courses/csep544/14wi/video/archive/html5/video.html?id=csep544_14wi_8

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend