Recursive views make it possible to write queries that cannot be written without recursion or iteration.
Example
- Find all (direct or indirect) prerequisite subjects of each course
The example view rec_prereq
is called the transitive closure of the prereq
relation, meaning that it is a relation that contains all pairs (cid
, pre
) such that pre
is a direct or indirect prerequisite of cid
.
Recursive views are required to be monotonic.
-
For each step of the recursion, the view must contain all of the tuples it contained in the previous step, plus possibly some more.
-
At some point, no tuple is added to the view after recursion. This final result is called the fixed point of the recursive view definition.