Pathfinding in the database