Database Theory: Understanding Logic, Rules, and Queries, Study notes of Database Programming

An overview of database theory, focusing on logic, processing, and query languages. It covers topics such as logic in database theory, logic processing, conjunctive queries, and universal relation data model. The document also mentions applications in data mining and materialized views.

Typology: Study notes

2011/2012

Uploaded on 07/15/2012

salagame
salagame 🇮🇳

4

(3)

36 documents

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
What is Database Theory?
A collection of studies, often connected to the
relational mo del of data.
Restricted forms of logic, between SQL and
full rst-order.
Dependency theory: generalizing functional
dependencies.
Conjunctive queries (CQ's): useful, decidable
special case.
\Universal relations" tting a database schema
into a single (virtual) relation.
1
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Database Theory: Understanding Logic, Rules, and Queries and more Study notes Database Programming in PDF only on Docsity!

What is Database Theory?

A collecti on of studies, often connected to the relational mo del of data.

 Restricted forms of logic, b etween SQL and full rst-order.

 Dep endency theory: generalizing functional dep endencies.

 Conjunctive queries (CQ's): useful, decidable sp ecial case.

 \Universal relations" tting a database schema into a single (virtual) relation.

Why Care?

A lot of this work was, quite frankly, done \for the fun of it." However, it turns out to have unexp ected applicati ons, as natural ideas often do:

 Information integration:

F Logic, CQ's, etc., used for expressing how information sources t together. F Recent work using universal-relati on to o | eliminates requirement that user understand a lot ab out the integrated schema.

 More p owerful query languages.

F Recursion needed in rep ositories, other applicati ons. F Database logic provided some imp ortant ideas used in SQL3 standard: seminaive evaluati on, strati ed negation.

 Potential application: constraints and triggers are inherently recursive. When do they converge?

  1. Other stu if I have time for it and/or there is class interest:

a) Data mining of databases. b) Materiali zed views, warehouses, data cub es.

Course Requirements

  1. The usual stu : midterm, nal, problem sets.
  2. A pro ject:

F Each student should attempt to implement an algorithm for one of the problems discussed in the class. F Your choice, but you should pick something that is combinatorially hard, i.e., the problem is dealing eciently with large cases.

F I'll suggest some problems as we go, and keep a list on the Web page.

Rules

Head :- Bo dy

 :- is read \if "

 Atom = predicate applied to arguments.

 Head is atom.

 Bo dy is logical AND of zero or more atoms.

 Atoms of b o dy are called subgoals.

 Head predicate is IDB intensional database = predicate de ned by rules. Bo dy subgoals may have IDB or EDB predicates.

 Datalog program = collecti on of rules. One IDB predicate is distinguished and represents result of program.

Meaning of Rules

The head is true for its arguments whenever there exist values for any local variables (those that app ear in the b o dy, but not the head) that make all the subgoals true.

Extensions

  1. Negated subgoals. Example:

cycle(F) :- req(F,F) & NOT source(F)

  1. Constants as arguments. Example:

req(F,"stdio.h") :- type(F,"cCode")

  1. Arithmetic subgoals. Example:

composite(A) :- divides(B,A) & B > 1 & B <> A

F Opp osite of an arithmetic atom is a relational atom.

Seminaive Evaluation

 More ecient approach to evaluating rules.

 Based on principle that if at round i a fact is inferred for the rst time, then we must have used a rule in which one or more subgoals were instantiated to facts that were inferred on round i 1.

 Thus, for each IDB predicate p, keep b oth relation P and relation P ; the latter represents the new facts for p inferred on the most recent round.

Outline of SNE Algorithm

  1. Initiali z e IDB relations by using only those rules without IDB subgoals.
  2. Initiali z e the -IDB relations to b e equal to the corresp onding IDB relations.
  3. In one round, for each IDB predicate p:

a) Compute new P by applying each rule for p, but with one subgoal treated as a -IDB relation and the others treated as the correct IDB or EDB relation. (Do for al l p ossible choices of the -subgoal.) b) Remove from new P all facts that are already in P. c) P := P [ P.

  1. Rep eat (3) until no changes to any IDB relation.

Mo dels

Mo del of rules + EDB facts = set of atoms selected to b e true such that

  1. An EDB fact is selected true i it is in the given EDB relation.
  2. All rules b ecome true under any instantiatio n of the variables. F Facts not stated true in the mo del are assumed false. F Only way to falsify a rule is to make each subgoal true and the head false.

 Minimal model = mo del + no prop er subset is a mo del.

 For a Datalog program with only nonnegated, relational atoms in the b o dies, the unique minimal mo del is what naive or seminaive evaluation pro duces, i.e., the IDB facts we are forced to deduce.

 Moreover, this LFP is reached after a nite numb er of rounds, if the EDB is nite.

Function Symb ols

Terms built from

  1. Constants.
  2. Variables.
  3. Function symb ols applied to terms as arguments.

F Example:

addr

str eet(mapl e); number (101)