If I were going to do this I would
-
Pull down a backup of the site and load it into a PostgreSQL database; PostgreSQL is the database backing Discourse. (ref)
-
Create a NoSQL database, specifically Neo4j, from the PostgreSQL data. (ref)
-
Use the Neo4j query language Cypher to find the realtionships.
Neo4j has a sandbox, you might find the Panama Papers example of interest.
EDIT
Once the Neo4j database is up an working to keep the Neo4j database in sync with the Discourse PostgreSQL database I would use either