This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 Datalog Logical Rules Recursion 2 Logic As a Query Language ◆ Ifthen logical rules have been used in many systems. ◗ Important example : EII (Enterprise Information Integration). ◆ Nonrecursive rules are equivalent to the core relational algebra. ◆ Recursive rules extend relational algebra and appear in SQL99. 3 Example : Enterprise Integration ◆ Goal : integrated view of the menus at many bars Sells(bar, beer, price) . ◆ Joe has data JoeMenu(beer, price) . ◆ Approach 1 : Describe Sells in terms of JoeMenu and other local data sources. Sells(’Joe’’s Bar’, b, p) < JoeMenu(b, p) 4 EII – (2) ◆ Approach 2 : Describe how JoeMenu can be used as a view to help answer queries about Sells and other relations. JoeMenu(b, p) < Sells(’Joe’’s Bar’, b, p) ◆ More about information integration later. 5 A Logical Rule ◆ Our first example of a rule uses the relations Frequents(drinker, bar) , Likes(drinker, beer) , and Sells(bar, beer, price) . ◆ The rule is a query asking for “happy” drinkers  those that frequent a bar that serves a beer that they like. 6 Anatomy of a Rule Happy(d) < Frequents(d,bar) AND Likes(d,beer) AND Sells(bar,beer,p) Body = antecedent = AND of subgoals . Head = consequent, a single subgoal Read this symbol “if” 7 Subgoals Are Atoms ◆ An atom is a predicate , or relation name with variables or constants as arguments. ◆ The head is an atom; the body is the AND of one or more atoms. ◆ Convention : Predicates begin with a capital, variables begin with lowercase. 8 Example : Atom Sells(bar, beer, p) The predicate = name of a relation Arguments are variables (or constants). 9 Interpreting Rules ◆ A variable appearing in the head is distinguished ; otherwise it is nondistinguished . ◆ Rule meaning : The head is true for given values of the distinguished variables if there exist values of the nondistinguished variables that make all subgoals of the body true. 10 Example : Interpretation Happy(d) < Frequents(d,bar) AND Likes(d,beer) AND Sells(bar,beer,p) Distinguished variable Nondistinguished variables Interpretation : drinker d is happy if there exist a bar, a beer, and a price p such that d frequents the bar, likes the beer, and the bar sells the beer at price p . 11 Applying a Rule ◆ Approach 1 : consider all combinations of values of the variables....
View
Full Document
 Fall '07
 Dr.Jeff
 Recursion, Relational model, IDB, AND Sells

Click to edit the document details