Presentation is loading. Please wait.

Presentation is loading. Please wait.

Recursion in SQL Nonlinear and Mutual Recursion.

Similar presentations


Presentation on theme: "Recursion in SQL Nonlinear and Mutual Recursion."— Presentation transcript:

1 Recursion in SQL Nonlinear and Mutual Recursion

2 Nonlinear & Mutual Recursion
SQL With Recursive Statement With Recursive R1 As (query-1), R2 As (query-2), ... Rn As (query-n) <query involving R1,…,Rn (and other tables)>

3 Nonlinear & Mutual Recursion
SQL With Recursive Statement With Recursive R As ( base query Union recursive query ) <query involving R (and other tables)>

4 Nonlinear & Mutual Recursion
Linear Recursion With Recursive R As ( base query Union recursive query ) <query involving R (and other tables)>

5 Nonlinear & Mutual Recursion
Example: Ancestors ParentOf(parent,child) Find all of Mary’s ancestors

6 Nonlinear & Mutual Recursion
Example: Ancestors ParentOf(parent,child) Find all of Mary’s ancestors

7 Nonlinear & Mutual Recursion
Example: Ancestors ParentOf(parent,child) Find all of Mary’s ancestors Nonlinear (versus linear) + Query looks cleaner + Converges faster – Harder to implement SQL standard only requires linear

8 Nonlinear & Mutual Recursion
SQL With Recursive Statement With Recursive R1 As (query-1), R2 As (query-2), ... Rn As (query-n) <query involving R1,…,Rn (and other tables)>

9 Nonlinear & Mutual Recursion
With Recursive R1 As (query-1), R2 As (query-2), ... Rn As (query-n) <query involving R1,…,Rn (and other tables)>

10 Nonlinear & Mutual Recursion
Example: Hubs & Authorities Link(src,dest) HubStart(node) AuthStart(node)

11 Nonlinear & Mutual Recursion
Example: Hubs & Authorities Link(src,dest) HubStart(node) AuthStart(node)

12 Nonlinear & Mutual Recursion
Example: Hubs & Authorities

13 Nonlinear & Mutual Recursion
Example: Recursion with Aggregation P(x)

14 Nonlinear & Mutual Recursion
SQL With Recursive Statement Extends expressiveness of SQL Basic functionality: linear recursion Extended functionality: nonlinear recursion, mutual recursion Disallowed: recursive subqueries (negative), aggregation With Recursive R1 As (query-1), R2 As (query-2), ... Rn As (query-n) <query involving R1,…,Rn (and other tables)>


Download ppt "Recursion in SQL Nonlinear and Mutual Recursion."

Similar presentations


Ads by Google