Discussion #24 1/17 Discussion #24 Deductive Databases.

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Logical Database Design (3 of 3) John Ortiz. Lecture 7Logical Database Design (2)2 Normalization  If a relation is not in BCNF or 3NF, we refine it by.
1 CHAPTER 4 RELATIONAL ALGEBRA AND CALCULUS. 2 Introduction - We discuss here two mathematical formalisms which can be used as the basis for stating and.
Chapter 5.2 Factoring by Grouping. 3y (2x – 7)( ) (2x – 7) (2x – 7) – 8 3y 1. Factor. GCF = (2x – 7) Find the GCF. Divide each term by the GCF. (2x –
SECTION 21.5 Eilbroun Benjamin CS 257 – Dr. TY Lin INFORMATION INTEGRATION.
1 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke Deductive Databases Chapter 25.
INFS614, Fall 08 1 Relational Algebra Lecture 4. INFS614, Fall 08 2 Relational Query Languages v Query languages: Allow manipulation and retrieval of.
From Variable Elimination to Junction Trees
Discussion #41/17 Discussion #4 Ambiguity & Precedence Grammars.
By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental.
Jeopardy $100 Topic 1Topic 2Topic 3Topic 4Topic 5 $200 $300 $400 $500 $400 $300 $200 $100 $500 $400 $300 $200 $100 $500 $400 $300 $200 $100 $500 $400.
1 9. Evaluation of Queries Query evaluation – Quantifier Elimination and Satisfiability Example: Logical Level: r   y 1,…y n  r’ Constraint.
SECTIONS 21.4 – 21.5 Sanuja Dabade & Eilbroun Benjamin CS 257 – Dr. TY Lin INFORMATION INTEGRATION.
By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental.
Matrices. Outline What is a matrix? Size of matrices Addition of matrices Scalar multiplication Matrices multiplication.
1 CMSC424, Spring 2005 CMSC424: Database Design Lecture 9.
CSE (c) S. Tanimoto, 2007 Unification 1 Unification Predicate calculus rules are sometimes so general that we need to create specializations of.
1 Module 32 Chomsky Normal Form (CNF) –4 step process.
Deductive Databases Chapter 25
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
DAVID DENG CS157B MARCH 23, 2010 Dependency Preserving Decomposition.
Polynomial Review What is a polynomial? An algebraic expression consisting of one or more summed terms, each term consisting of a coefficient and one or.
Which is equivalent to x 15 ? a. (x 3 )(x 5 ) b. (x 3 ) 5 c. (3x)(5x) d. (x 2 )(x 4 )/x 21.
February 14 th copyright2009merrydavidson. RATIONAL EXPONENTS 1) Anything to a power of zero =. 1 1.
Chapter 2 Section 5 Multiplying Integers. Multiplying Two Integers with Different Signs Words: The product of two integers with different signs. Numbers:
Relational Algebra (Chapter 7)
Datalog Inspired by the impedance mismatch in relational databases. Main expressive advantage: recursive queries. More convenient for analysis: papers.
1 Querying Infinite Databases Safety of Datalog Queries over infinite Databases (Sagiv and Vardi ’90) Queries and Computation on the Web (Abiteboul and.
1 Relational Algebra and Calculas Chapter 4, Part A.
1.1 CAS CS 460/660 Introduction to Database Systems Relational Algebra.
1 Relational Algebra Chapter 4, Sections 4.1 – 4.2.
Minimum Cover of F. Minimal Cover for a Set of FDs Minimal cover G for a set of FDs F: –Closure of F = closure of G. –Right hand side of each FD in G.
CONSENSUS THEOREM Choopan Rattanapoka.
CMPT 258 Database Systems Relational Algebra (Chapter 4)
Factoring Binomials Algebra Lesson 9-5. Let’s Review 1) 6ab + 3a 2) 5x 3 – 3y 2 3) 2c 4 – 4c 3 + 6c 2 4) 4w 4n + 12w 4n+3.
Functional dependencies CMSC 461 Michael Wilson. Designing tables  Now we have all the tools to build our databases  How should we actually go about.
Jeopardy $100 Topic 1Topic 2Topic 3Topic 4 $200 $300 $400 $500 $400 $300 $200 $100 $500 $400 $300 $200 $100 $500 $400 $300 $200 $100 Final Jeopardy Final.
Reducing Number of Candidates Apriori principle: – If an itemset is frequent, then all of its subsets must also be frequent Apriori principle holds due.
Relational Algebra. What is an algebra? –a pair: (set of values, set of operations) –  ADT  type  Class  Object e.g., stack: (set of all stacks, {pop,
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
Multiply matrices Use the properties of matrix multiplication.
CS589 Principles of DB Systems Fall 2008 Lecture 4c: Query Language Equivalence Lois Delcambre
CS589 Principles of DB Systems Spring 2014 Unit 2: Recursive Query Processing Lecture 2-1 – Naïve algorithm for recursive queries Lois Delcambre (slides.
Reducing Number of Candidates
Relational Data Model.
CS4432: Database Systems II
Relational Algebra Chapter 4 1.
Goal for this lecture Demonstrate how we can prove that one query language is more expressive than (i.e., “contained in” as described in the book) another.
52 Exponent Base 52 · 53 = 55 If the numerical bases are the same, keep the base and add the exponents.
Relational Algebra.
Jess Architecture Diagram WORKING MEMORY INFERENCE ENGINE EXECUTION ENGINE PATTERN MATCHER RULE BASE Here you can see how all the parts fit.
Relational Algebra Chapter 4 1.
Relational Algebra Chapter 4, Sections 4.1 – 4.2
Multiplying monomials with monomial
Jeopardy Final Jeopardy Topic 1 Topic 2 Topic 3 Topic 4 Topic 5 $100
Overview Part 2 – Circuit Optimization
Logic Based Query Languages
Datalog Inspired by the impedance mismatch in relational databases.
Jeopardy Final Jeopardy Topic 1 Topic 2 Topic 3 Topic 4 Topic 5 $100
Jeopardy Final Jeopardy Topic 1 Topic 2 Topic 3 Topic 4 Topic 5 $100
Jeopardy Final Jeopardy Topic 1 Topic 2 Topic 3 Topic 4 Topic 5 $100
Jeopardy Final Jeopardy Topic 1 Topic 2 Topic 3 Topic 4 Topic 5 $100
Algebraic Deduced Identities
Jeopardy Final Jeopardy Topic 1 Topic 2 Topic 3 Topic 4 Topic 5 $100
Jeopardy Final Jeopardy Topic 1 Topic 2 Topic 3 Topic 4 Topic 5 $100
Jeopardy Final Jeopardy Topic 1 Topic 2 Topic 3 Topic 4 Topic 5 $100
Jeopardy Final Jeopardy Topic 1 Topic 2 Topic 3 Topic 4 Topic 5 $100
Jeopardy Final Jeopardy Topic 1 Topic 2 Topic 3 Topic 4 Topic 5 $100
Jeopardy Final Jeopardy Topic 1 Topic 2 Topic 3 Topic 4 Topic 5 $100
Presentation transcript:

Discussion #24 1/17 Discussion #24 Deductive Databases

Discussion #24 2/17 Topics Deductive Databases Turning Datalog into Relational Algebra Recursive Rules & the Least Fixed Point Algorithm

Discussion #24 3/17 Deductive Databases Deductive database management systems answer queries based on methods related to proofs from rules and facts. Relational algebra operations can be used to more efficiently process deductive database queries.

Discussion #24 4/17 Correspondence Between Relational Databases & Deductive Databases Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(y,x). b(x,y) :- f(x,z),f(z,y). Queries: b(1,x)? f(A, B) b(C, D) b  b   x  C  y  D  xy (  A  y  B  x f ) b  b   x  C  y  D  xy (  A  x  B  z f |  |  A  z  B  y f)  x  D  x  C=1 b

Discussion #24 5/17 Correspondence Between Relational Databases & Deductive Databases Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(y,x). b(x,y) :- f(x,z),f(z,y). Queries: b(1,x)? f(A, B) b(C, D) b  b   x  C  y  D  xy (  A  y  B  x f ) b  b   x  C  y  D  xy (  A  x  B  z f |  |  A  z  B  y f)  x  D  x  C=1 b

Discussion #24 6/17 Correspondence Between Relational Databases & Deductive Databases Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(y,x). b(x,y) :- f(x,z),f(z,y). Queries: b(1,x)? f(A, B) b(C, D) b  b   x  C  y  D  xy (  A  y  B  x f ) b  b   x  C  y  D  xy (  A  x  B  z f |  |  A  z  B  y f)  x  D  x  C=1 b

Discussion #24 7/17 Correspondence Between Relational Databases & Deductive Databases Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(y,x). b(x,y) :- f(x,z),f(z,y). Queries: b(1,x)? f(A, B) b(C, D) b  b   x  C  y  D  xy (  A  y  B  x f ) b  b   x  C  y  D  xy (  A  x  B  z f |  |  A  z  B  y f)  x  D  x  C=1 b x123x123 or x = 1 x = 2 x = 3

Discussion #24 8/17 Correspondence Between Relational Databases & Deductive Databases Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(y,x). b(x,y) :- f(y,y),f(2,x). Queries: b(1,x)? f(A, B) b(C, D) b  b   x  C  y  D  xy (  A  y  B  x f ) b  b   x  C  y  D  xy (  A  y  A  A=B f |  |  B  x  B  A=2 f)  x  D  x  C=1 b

Discussion #24 9/17 Correspondence Between Relational Databases & Deductive Databases Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(y,x). b(x,y) :- f(y,y),f(2,x). Queries: b(1,x)? f(A, B) b(C, D) b  b   x  C  y  D  xy (  A  y  B  x f ) b  b   x  C  y  D  xy (  A  y  A  A=B f |  |  B  x  B  A=2 f)  x  D  x  C=1 b

Discussion #24 10/17 Correspondence Between Relational Databases & Deductive Databases Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(y,x). b(x,y) :- f(y,y),f(2,x). Queries: b(1,x)? f(A, B) b(C, D) b  b   x  C  y  D  xy (  A  y  B  x f ) b  b   x  C  y  D  xy (  A  y  A  A=B f |  |  B  x  B  A=2 f)  x  D  x  C=1 b x1x1 or x = 1

Discussion #24 11/17 Correspondence Between Relational Databases & Deductive Databases Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(y,x). b(x,y) :- f(y,y),f(2,x). Queries: b(x,x)? f(A, B) b(C, D) b  b   x  C  y  D  xy (  A  y  B  x f ) b  b   x  C  y  D  xy (  A  y  A  A=B f |  |  B  x  B  A=2 f)  x  C  x  C  C=D b x1x1 or x = 1

Discussion #24 12/17 Rule Order & Recursive Rules Rules may appear in any order. Rules may be recursive. To handle this, we repeatedly execute rules in any order and quit when we deduce no new facts (least fixed point algorithm).

Discussion #24 13/17 Least Fixed Point Algorithm Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(x,y). b(x,y) :- f(x,z),b(z,y). Queries: b(1,3)? Least Fixed Point Algorithm –Start with an empty set S –Add to S repeatedly until no more changes. Essentially: b  { } repeat: b  b  f b  b  (f |  | b) until no change result  “yes” if not empty:  C=1  D=3 b

Discussion #24 14/17 Set Up Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(x,y). b(x,y) :- f(x,z),b(z,y). Queries: b(1,3)? Before unioning, sets must be union compatible. Before joining, attributes must observe variable sameness and differences. b  { } repeat: b  b   A  C  B  D f b  b   CD  A  C (f |  |  C  B b) until no change result  “yes” if not empty:  C=1  D=3 b Note: these renamings are “human determined.” Use renamings as described earlier for programming.

Discussion #24 15/17 1 st Iteration Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(x,y). b(x,y) :- f(x,z),b(z,y). Queries: b(1,3)? b  { } repeat: b  b   A  C  B  D f b  b   CD  A  C (f |  |  C  B b) until no change result  “yes” if not empty:  C=1  D=3 b b(C,D)  b(C,D)  f(A,B) f(C,D) ACBDfACBDf b(C,D) b(C,D)  b(C,D)  f(A,B) |  | b(C,D) f(A,B) |  | b(B,D) = t(A,B,D) CBbCBb t(C,B,D)  CD  A  C t b changed! So, repeat.

Discussion #24 16/17 2 nd Iteration Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(x,y). b(x,y) :- f(x,z),b(z,y). Queries: b(1,3)? b  { } repeat: b  b   A  C  B  D f b  b   CD  A  C (f |  |  C  B b) until no change result  “yes” if not empty:  C=1  D=3 b b(C,D)  b(C,D)  f(A,B) b(C,D)  b(C,D)  f(A,B) |  | b(C,D) f(A,B) |  | b(B,D) = t(A,B,D) CBbCBb t(C,B,D)  CD  A  C t f hasn’t changed  so no change here b did NOT change, so done. duplicate

Discussion #24 17/17 Query Finalization Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(x,y). b(x,y) :- f(x,z),b(z,y). Queries: b(1,3)? b  { } repeat: b  b   A  C  B  D f b  b   CD  A  C (f |  |  C  B b) until no change result  “yes” if not empty:  C=1  D=3 b b(1,3)? So, finally…  C=1  D=3 b(C,D)? = C,D = not empty = Yes b(2,2)? No b(1,X)? Yes X = 1 X = 2 X = 3 b(2,X)? Yes X = 3