Recursion, the SQL way
Recursion reached SQL late, as the recursive common table expression.
WITH RECURSIVE computes a fixed point, exactly the metro reachability from Part 2:
WITH RECURSIVE reach(src, dst) AS (
SELECT src, dst FROM line
UNION
SELECT line.src, reach.dst
FROM line JOIN reach ON line.dst = reach.src
)
SELECT * FROM reach;
But standard SQL allows only linear recursion: the recursive case may name
reach just once.
The doubly-recursive transitive closure and the parser cannot be expressed in plain SQL.