Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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:

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

2 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 (  - )

3 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).

4 Insert Rules: r1­i.  + Route(c1,c2) :-  + Train(c1,c2). r2­i1.  + Route(c1,c2) :-  + Route(c1,c3), Route(c3,c1). 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).

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

6 Reinsert rules 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).

7 From Deductive Rules to Production Rules-- Revisited  Deductive rules for transitive closure of base(fr, to): closure(X,Y) :­ base(X,Y) closure(X,Y) :­ closure(X,Z), base(Z,Y).  + closure(X,Y) :­  + base(X,Y).  + closure(X,Y) :­  + closure(X,Z), base(Z,Y).  + closure(X,Y) :­ closure(X,Z),  + base(Z,Y).  Can we turn these into production rules? insert into closure (select * from base)  Production rule create rule trans­closure on closure when inserted then insert into closure (select inserted.fr, closure.to from inserted, closure where inserted.to = closure.fr)  There is a problem with this rule—what is it?

8 Computing Transitive Closure with the Delta Rules  Deductive rules for transitive closure of base(fr, to): closure(X,Y) :­ base(X,Y) closure(X,Y) :­ closure(X,Z), closure(Z,Y).  + closure(X,Y) :­  + base(X,Y)  + closure(X,Y) :­  + closure(X,Z), closure(Z,Y).  + closure(X,Y) :­ closure(X,Z),  + closure(Z,Y).  We can emulate the first rule by taking each tuple in base and adding to closure(fr, to): insert into closure (select * from base)  Production rule create rule trans­closure on closurewhen inserted then insert into closure (select inserted.fr, closure.to from inserted, closure where inserted.to = closure.fr) UNION (select closure.fr, inserted.to where closure.to = inserted.fr)

9 Positive Delta Maintenance  We now need a rule to perform to start the updating of closure every time we add to base: create rule deltaplus on base when inserted then insert into closure select * from inserted More problems: you must also check that the tuple is not already in closure.


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


Ads by Google