workerjoe
workerjoe

Reputation: 2663

How to discover associations between tables in a PostgreSQL database?

I'm dealing with a huge ERP database, hundreds of tables, and am having trouble figuring out how one entity is referenced from another. Let's call them the "sale" table and the "shipment" table. Each has FK relationships with numerous other tables, but no FK links either one to the other, and no obvious associative table is linked to both.

  1. Is there any good way using SQL or the psql command line to discover the chains of relationships that connect the two tables?
  2. Is there any good way to discover the chains that connect a specific row or PK of "sale" and a specific row/PK of "shipment"?

Upvotes: 0

Views: 411

Answers (1)

Arkhena
Arkhena

Reputation: 280

You should look at a tool like schemacrawler. It's good a opensource tool for data modelling retro-engineering.

You can find documentation here.

Upvotes: 1

Related Questions