

With the town and library part of the database working well, we'll finish off the tour of SurrealDB by showing another one of its newest features: recursive queries and algorithms. Recursive queries let you move down multiple depths, while algorithms let you tell the database to follow all possible paths with a certain objective.
To make this happen, we'll first fill out the downtown section of Riverdale which you've seen throughout this tour in the image at the top. SurrealDB has three algorithms that help answer questions like this:
What is the shortest path from Event Junction to Vector Park?
What are all the paths within two steps from Event Junction? e.g. Event Junction to Index Avenue to Surreal Square, or Event Junction to Index Avenue to Statement Street...
What are all the unique paths within two steps from Event Junction? e.g. Index Avenue, Surreal Square, Statement Street, but not Vector Park, which is much more than two steps away.
Try looking at the image on top as you think about what the answers might be.
To set the stage for this, we'll first need to add all of these streets and places. This could be done using RELATE statements, but simple record links work just as well so we will go with record links this time.
{/ Todo: change from future /}
The street called Bowler Hat Alley, by the way, is the little one that provides a shortcut from Rust Row to Index Avenue and has a building with an actual bowler hat on the top.
Also note that one of the streets is an interesting one, a set of bridges and stairs that cross the river at the bottom of the image. This mysterious location is a bit of a maze. Sometimes it takes you to where you want to go, but other times you can't find your way out, and other times you end up back at the place where you entered. That's why locals call it Recursive Crossing.
That's why this one is connected not only to two streets, but also to itself, and the value NONE.