24-DeducDatabases

# Databases deductive databases schemes fab bcd facts

• Notes
• 17

This preview shows page 11 - 16 out of 17 pages.

Databases & Deductive Databases Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(y,x). b(x,y) :- f(y,y),f(2,x). Queries: b(x,x)? f(A, B) b(C, D) 1 1 1 1 1 2 2 1 2 3 3 2 3 1 b b ρ x C ρ y D π xy ( ρ A y ρ B x f ) b b ρ x C ρ y D π xy ( ρ A y π A σ A=B f | × | ρ B x π B σ A=2 f) π x ρ C x σ C=D b x 1 or x = 1

Subscribe to view the full document.

Discussion #24 Deductive Databases 12/21 Rule Order & Recursive Rules Rules may appear in any order. Rules may be recursive. To handle this, we repeatedly execute rules in any order and quit when we deduce no new facts (least fixed point algorithm).
Discussion #24 Deductive Databases 13/21 Least Fixed Point Algorithm Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(x,y). b(x,y) :- f(x,z),b(z,y). Queries: b(1,3)? Least Fixed Point Algorithm Start with an empty set S Add to S repeatedly until no more changes. Essentially: b { } repeat: b b f b b f | × | b until no change result “yes” if not empty: σ C=1 σ D=3 b

Subscribe to view the full document.

Discussion #24 Deductive Databases 14/21 Set Up Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(x,y). b(x,y) :- f(x,z),b(z,y). Queries: b(1,3)? Before unioning, sets must be union compatible. Before joining, attributes must observe variable sameness and differences. b { } repeat: b b ρ A C ρ B D f b b π CD ρ A C (f | × | ρ C B b) until no change result “yes” if not empty: σ C=1 σ D=3 b Note: these renamings are “human determined.” Use renamings as described earlier for programming.
Discussion #24 Deductive Databases 15/21 1 st Iteration Schemes: f(A,B) b(C,D) Facts: f(1,1). f(1,2). f(2,3). Rules: b(x,y) :- f(x,y). b(x,y) :- f(x,z),b(z,y). Queries: b(1,3)? b { } repeat: b b ρ A C ρ B D f b b π CD ρ A C (f | × | ρ C B b) until no change result “yes” if not empty: σ C=1 σ D=3 b b(C,D) b(C,D) f(A,B) f(C,D) 1 1 1 2 2 3 1 1 1 2 2 3 ρ A C ρ B D f b(C,D) b(C,D) b(C,D) f(A,B) | × | b(C,D) f(A,B) | × | b(B,D) = t(A,B,D) 1 1 1 1 1 1 1 1 2 1 2 1 1 2 2 3 2 3 1 2 3 1 1 1 2 2 3 ρ C B b t(C,B,D) 1 1 1 1 1 2 1 2 3

Subscribe to view the full document.

You've reached the end of this preview.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern