8-datalog

8-datalog - DATALOG CS273 - Data and Knowledge Bases Xifeng...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
DATALOG CS273 - Data and Knowledge Bases Xifeng Yan Computer Science niversity of California at Santa Barbara University of California at Santa Barbara
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Department of Computer Science QL is Not Enough! SQL is Not Enough! CS273: Data and Knowledge Bases | University of California at Santa Barbara 2
Background image of page 2
Department of Computer Science Domain Relational Calculus Queries have form: 1 x2 n p} predicate {x1,x2, …, xn| p } Predicate: boolean expression over x1,x2, …, xn domain variables We have the following operations: x i op x j x i op const const op x i p p x i . p x j . p p q, p q p, p q where op is , , , , , and x i ,x j ,… are domain variables; p,q are predicates ecall that this captures the same expressiveness as the Recall that this captures the same expressiveness as the relational algebra CS273: Data and Knowledge Bases | University of California at Santa Barbara 3 slides by courtesy of Ives with modifications
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Department of Computer Science Logic-Based Language: Datalog Borrows the flavor of the relational calculus Based on the Prolog logic-programming language A “datalog program” will be a series of if-then rules that define relations from predicates Rules are generally of the form: R out (T 1 ) R 1 (T 2 ), R 2 (T 3 ), …, c(T 2 ,…T n ) where R out is the relation representing the query result, R i are predicates representing relations , c is an expression using arithmetic/boolean predicates over vars, and T are tuples of variables i p CS273: Data and Knowledge Bases | University of California at Santa Barbara 4
Background image of page 4
Department of Computer Science Datalog Terminology An example datalog rule: idb(x,y) r1(x,z), r2(z,y), z < 10 body head subgoals Irrelevant variables can be replaced by _ ( anonymous var) xtensional relations r database schemas ( dbs are Extensional relations or database schemas ( edbs ) are relations only occurring in rules’ bodies – these are base relations with “ground facts” Intensional relations ( idbs ) appear in the heads – these are basically views istinguished variables re the ones output in the head CS273: Data and Knowledge Bases | University of California at Santa Barbara 5 Distinguished variables are the ones output in the head Ground facts only have constants, e.g., r1(“abc”, 123)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Department of Computer Science Datalog in Action
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 19

8-datalog - DATALOG CS273 - Data and Knowledge Bases Xifeng...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online