SchemaSpy Org ERD

Winter ’12 has a built in ERD viewer – see e.g. An ERD is Worth a Thousand Words: Schema Builder in Winter ’12 – that may meet some or all of your ERD needs so take a look at that first before considering the approach described below.

The force-metadata-jdbc-driver open source project is one way to produce an Entity Relationship Diagram (ERD) of the objects in your org.

Some background. I looked around for a data modeling tool for that can output a complete data model but didn’t find one. (SoqlXplorer for OSX can produce diagrams but is an interactive tool. Explorer is limited in its beta form. Other suggestions very welcome.) In the past when working with conventional JDBC databases I have used SchemaSpy. The cool thing about this is that the diagrams are automatically laid out in a rational way, and the accompanying HTML provides extra information and hyperlinking. So you get complete documentation of your schema without any manual intervention. In our environment, the model is generated on every Jenkins build.

The opportunity to use SchemaSpy for comes from the fact that SchemaSpy primarily uses the java.sql.DatabaseMetaData interface part of the JDBC API which is relatively small and easy to implement. So with the benefit of SchemaSpy being open source to allow inspection and debugging, I went ahead and created a JDBC driver that uses the enterprise (now partner) web service (DescribeSObjectResult, Field etc) to implement the parts of the JDBC API that SchemaSpy uses. That allows SchemaSpy to produce its output for a org.

The full output consists of multiple diagrams and HTML pages that document all the objects, their fields and the object relationships. Here is an example of one of the diagrams:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s