title: Generate an E-R Diagram by reverse-engineering a database
body: <p><em>Note: Originally this question was asked for PostgreSQL, however, the answer applies to almost any database which has a JDBC driver that can detect foreign-key associations.</em> </p>
  
  <hr>
  
  <p>Querying PostgreSQL data dictionary for foreign-keys and relationship between tables is very straightforward, but how can I use that information to generate a graph of the relations between tables?</p>
  
  <p>Any recommendations about tools that can do this?</p>
  
  <p><strong>EDIT:</strong> I know GraphVIZ/DOT <em>can</em> be useful, however, I don't know have any idea regarding how to code an app that would generate the directed graph .DOT file.</p>