Recursion and Datalog Flashcards

1
Q

_______ languages extend query languages with recursion

A

datalog

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The _______ in a datalog rule contains predicates over variables and constants

A

head

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The _______ in a datalog rule contains conjunctions of possibly negated items

A

body

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Head variables are implicitly _________ quantified

A

universally

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Body variables are implicitly _________ quantified

A

existentially

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In datalog rules, if the _______ is true, the ______ is true

A

body, head

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Translate the datalog rule Lucky(x) :- Customer(x, y, z), Account(u, z, x, w), w > 10000 to RC

A

Lucky = { x | 9y, z, u, w Customer(x, y, z)^ Account(u, z, x, w) ^ w > 10000}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When converting from datalog to RC, for safety’s sake, every variable in the _____ or ______ needs to appear in one non-negated ___________ atom

A

Head, body, relational

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A datalog program is a _____ of datalog rules

A

set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Extensional DB relations are __________ in the database

A

stored

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Intensional DB relations are __________ relations

A

derived

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

EDB relations appear in the _____ of rules

A

body

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

IDB relations appear in the ____ or _____ of rules

A

head, body

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Translate projection_(#2)(R) to datalog

A

E(x) :- R(y, x)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Translate selection_(#1 op c)(R) to datalog

A

E(x, y) :- R(x, y), x op c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Translate R x S to datalog

A

E(x, y, w, z) :- R(x, y), S(w, z)

17
Q

Translate R - S to datalog

A

E(x, y) :- R(x, y), ¬S(x, y)

18
Q

Translate R U S to datalog

A

E(x, y) :- R(x, y) and

E(x, y) :- S(x, y)

19
Q

The head relation of a ______ can appear in its body

A

rule

20
Q

IDB predicate _______ ____ predicate Q

A

depends on

21
Q

In a dependency graph, ______ are IDB predicates, and _______ are the dependencies P -> Q

A

nodes, edges

22
Q

A _______ in the dependency graph means the datalog program as recursive

A

cycle

23
Q

The _____ never changes

A

EDB

24
Q

The _____ is initially empty

A

IDB

25
Q

What is a fixed point?

A

When the next step of a recursion equals the previous step

26
Q

Recall the SQL query to mimic the ancestor parent datalog rule:
Ancestor(x, y) :- Parent(x, y)
Ancestor(x, y) :- Ancestor(x, z), Parent(z, y)

A
WITH RECURSIVE Ancestor(name, descendant) AS (
SELECT *
FROM Parent
UNION
SELECT A.name, P.child
FROM Ancestor A, Parent P
WHERE A.descendant = P.name
)
SELECT * FROM Ancestor ;
27
Q

In ___________ recursion, the head relation appears more than once in its body

A

nonlinear

28
Q

Nonlinear recursion is not _________ in SQL

A

supported

29
Q

A recursive program with no ________ never ends

A

fixpoint

30
Q

If a relation S is used positively in the definition of R

then S must be defined ________ or ______________ with R

A

earlier, simultaneously

31
Q

If a relation S is used __________ in the definition of R

then S must be defined strictly before R

A

negatively

32
Q

A stratum graph is similar to a dependency graph except that edges are labelled with a “-“ if it is a ________ subgoal

A

negated

33
Q

A _________ program has no cycle involving at least one negated edge

A

stratified

34
Q

SQL recursion requires ________ negation and only uses ______ recursion

A

stratified, linear