There seem to be two "thought camps" with regard to how to extend relational query languages in order to better deal with graph processing so that one does not have to write as much procedural "pointer hopping" and looping app code when dealing with graphs, DAG's, and trees.
One approach is to add recursion to the query language, and a second is to add "traversal" operation(s) that are declarative in nature. The recursive approach may be more flexible, but turns the query writer into a functional programmer. Although FP proponents will be happy with this, some argue it takes away from the declarative nature of query languages.
Traveral Operation Proposal
Here is a rough draft of a generic "traversal" operation. (Roughly based on RelationalAndTrees.) Basically we are assuming a many-to-many table with a matching "from" key set and a "to" key set. I use the word "set" because the keys may be compound keys. Some many-to-many tables don't fit this structure, but most can be converted/projected to this structure via various relational operators (UNION, JOIN, Etc.) via nested or referenced queries.
Inputs
Outputs
Issues
Note that any non-traversal-related filtering (WHERE clause) would be done before this operation, although for convenience we may want to include it. But for simplicity it will not be considered here.
Hypothetical SQL Example:
Table: roomstouch
---------
buildingID
roomID // unique only within a given building
buildingLink
roomLink
otherStuff
SELECT *, depth() AS depth, parent() AS parent
TRAVERSE FROM roomstouch
FROMKEY buildingID, roomID
TOKEY buildingLink, roomLink
START AT 23, 7
MAXDEPTH 5
Other possible optional features:
Perhaps a better title would be "DeclarativeTraversalVersusRecursion".