# CS240A: Databases and Knowledge Bases From Deductive Rules to Active Rules Carlo Zaniolo Department of Computer Science University of California, Los Angeles.

## Presentation on theme: "CS240A: Databases and Knowledge Bases From Deductive Rules to Active Rules Carlo Zaniolo Department of Computer Science University of California, Los Angeles."— Presentation transcript:

CS240A: Databases and Knowledge Bases From Deductive Rules to Active Rules Carlo Zaniolo Department of Computer Science University of California, Los Angeles Revised: January 2003

From Deductive Rules to Production Rules  Deductive rules for recursive views: closure(X,Y) :­ base(X,Y) closure(X,Y) :­ closure(X,Z), base(Z,Y)  Active rules to materialize recursive views:  Initialization step (will start the process) insert into closure (select * from base)  Production rule (will call itself recursively, several times) create rule trans­closure on base when inserted then insert into closure (select inserted.fr, closure.to from inserted, closure where inserted.to = closure.fr)

Maintenance  Every time the database is changed recompute the concrete view, or  Perform delta maintenance using techniques similar to the differential fixpoint of deductive databases  Things are more complex here because you can have both additions (  + ) an subtractions (  - )

Example of Recursive View  Database: Station(city, state). Train(city1, city2).  Deductive rules: r1. Route(c1,c2) :­ Train(c1,c2). r2. Route(c1,c2) :­ Route(c1,c3), Route(c3,c2). r3. ReachCal(c) :­ Station(c,s), s = ''California'‘. r4. ReachCal(c) :­ Route(c,c2), ReachCal(c2).

Insert Rules: r1­i.  + Route(c1,c2) :-  + Train(c1,c2). r2­i1.  + Route(c1,c2) :-  + Route(c1,c3), Route(c3,c2). r2­i2.  + Route(c1,c2) :- Route(c1,c3),  + Route(c3,c2). r3­i.  + ReachCal(c) :-  + Station(c,s), s = ''California'' r4­i1.  + ReachCal(c) :-  + Route(c,c1), ReachCal(c1). r4­i2.  + ReachCal(c) :- Route(c,c1),  + ReachCal(c1).

Delete Rules Eliminate all suspect arcs r1­d.  - Route(c1,c2) :-  - Train(c1,c2) r2­d1.  - Route(c1,c2) :-  - Route(c1,c3), Route(c3,c2) r2­d2.  - Route(c1,c2) :- Route(c1,c3),  - Route(c3,c2) r3­d.  - ReachCal(c) :-  - Station(c,s), s = ''California'' r4­d1.  - ReachCal(c) :-  - Route(c,c1), ReachCal(c1) r4­d2.  - ReachCal(c) :- Route(c,c1),  - ReachCal(c1) NB. Train, Route, Station, ReachCal: before deletion

Reinsert rules (needed after deletion) r1­r.  + Route(c1,c2) :­  - Route(c1,c2), Train(c1,c2). r2­r.  + Route(c1,c2) :­  - Route(c1,c2), Route(c1,c3), Route(c3,c2). r3­r.  + ReachCal(c) :­  - ReachCal(c), Station(c,s), s = ''California'' r4­r.  + ReachCal(c) :­  - ReachCal(c), Route(c,c1),ReachCal(c1).  Train, Route, Station, ReachCal: after deletion   - restricts search in a fashion similar to magic sets.

Download ppt "CS240A: Databases and Knowledge Bases From Deductive Rules to Active Rules Carlo Zaniolo Department of Computer Science University of California, Los Angeles."

Similar presentations