Hacker News new | ask | show | jobs
by ttfkam 1270 days ago

  WITH RECURSIVE
is how graph/tree queries work in modern SQL (assuming you aren't using something like ltree [0]. The first part of the recursive CTE identifies the root record and then UNION ALL with the subsequent items referencing what came before.

Is it as easy as a Cypher query in Neo4j? Not all all. But it is arguably more flexible in that you can represent far more data structures and link to non-graph data easily.

I just unwrapped nested JSON columns into a flat key-value set with it last week. It's deceptively powerful.

[0] https://www.postgresql.org/docs/current/ltree.html