ThatJeffSmith

How To: Generate an ERD for Selected Tables in SQL Developer

Entity Relationship Diagrams tell a story. An employee is assigned one department. A location can house one or more departments. Jeff doesn’t have a boss because he is ‘the man.’ It can be challenging to understand the nature of your data by simply reading through the list of Foreign Key constraints for a table. Who wants to read this

Foreign keys - they do exist!

when you can instead see this

A pretty picture is worth a few dozen DDL scripts?

So how do you go from one to the other?

Today it requires just a few steps:

Open the Data Modeler Browser in SQL Developer

View .. Data Modeler .. Browser

This will give you a new panel, underneath your Connections|Reports panel.

Go to the Relational Models node in the Tree

Right-mouse-click, ‘New Relational Model’

This will give you a blank model workspace.

Select your table(s) from the connection tree and drag them to the model space.

Voila, instant ERD! The only problem is that you will need to KNOW which objects to drag and drop. The Data Modeler will not automatically recursively search for related objects by foreign key constraint and add those tables. However, if you do add tables one at a time, it will auto-generate the relationship if there is one defined in the database.

I know what you’re thinking, ‘Shouldn’t this be easier?’

Maybe watching the movie will help?

ctrl_drag_model

Stay thirsty my friends!

Update! SQL Developer can automatically add ‘child tables.’

If you hold down CTRL while you drag, it will bring in all related subordinate objects. Thanks for the heads-up Philip (the guy who wrote the code!) For an example, take HR.REGIONS and Ctrl drag it to a model. You’ll get EMPLOYEES, DEPARTMENTS, JOB_HISTORY, etc all auto-added to the model. Pretty slick!