For the graph database idea in Postgres, PG 19 has native support for property graphs [0]. You can set up your tables and their relationships as nodes/edges, then query against them using Cypher-esque [1] syntax.
0: https://www.postgresql.org/docs/19/ddl-property-graphs.html