Deductive Database
Deductive Database
Recursive Queries
Assembly(part,subpart, qty)
Remember fixed point == stable state == no further deduction possible == f(v) -> v
Least fixed point - is fixed point smaller than any other fixed point
b. Solving Problem 2 –
SameLevel(subpart1,subpart2) :- assembly(part1,subpart1,q1), assembly(part1,subpart2,q2)
SameLevel(subpart1,subpart2) :- assembly(part1,subpart1,q1),
assembly(part2,subpart2,q2), samelevel(part1,part2)
But calculating same level for all part is wastefull, so instead we will use Magic Set
Transformation
We will create MagicSameLevel, where we will calulcate samelevel where argument in query
is given part
MagicSameLevel(part):- MagicSameLevel(subpart), assembly(part,subpart,q)
It restricts the query search space to relevent fields thereby improving its time complexity
Algorithm
1. Generate Adorned Program – program is rewritten for clarification ofqueries and
subqueries
2. Add Magic Filters – Modify rules in Adorned program, by adding magic condition to
the body that acts as a filter to tuples generated by the rules
3. Define Magic Table