{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# slides14 - Schedule Today Feb 26(T x x Datalog Read...

This preview shows pages 1–6. Sign up to view the full content.

Winter 2002 Arthur Keller – CS 180 14–1 Schedule Today: Feb. 26 (T) Datalog. Read Sections 10.1-10.2. Assignment 6 due. Feb. 28 (TH) Datalog and SQL Recursion, ODL. Read Sections 10.3-10.4, 4.1-4.4. Project Part 6 due. Mar. 5 (T) More ODL, OQL. Read Sections 9.1. Assignment 7 due. Mar. 7 (TH) More OQL. Read Sections 9.2-9.3.

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

View Full Document
Winter 2002 Arthur Keller – CS 180 14–2 Logical Query Languages Motivation: 1. Logical rules extend more naturally to recursive queries than does relational algebra. Used in SQL recursion. 2. Logical rules form the basis for many information-integration systems and applications.
Winter 2002 Arthur Keller – CS 180 14–3 Datalog Example Likes(drinker , beer ) Sells(bar , beer , price) Frequents(drinker , bar ) Happy(d) <- Frequents(d,bar) AND Likes(d,beer) AND Sells(bar,beer,p) Above is a rule . Left side = head . Right side = body = AND of subgoals . Head and subgoals are atoms . Atom = predicate and arguments. Predicate = relation name or arithmetic predicate, e.g . <. Arguments are variables or constants. Subgoals (not head) may optionally be negated by NOT .

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

View Full Document
Winter 2002 Arthur Keller – CS 180 14–4 Meaning of Rules Head is true of its arguments if there exist values for local variables (those in body, not in head) that make all of the subgoals true. If no negation or arithmetic comparisons, just natural join the subgoals and project onto the head variables. Example Above rule equivalent to Happy(d) = π drinker (Frequents Likes Sells)
Winter 2002 Arthur Keller – CS 180 14–5 Evaluation of Rules Two, dual, approaches: 1. Variable-based : Consider all possible assignments of values to variables. If all subgoals are true, add the head to the result relation. 2. Tuple-based : Consider all assignments of tuples to subgoals that make each subgoal true. If the variables are assigned consistent values, add the head to the result.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}