Creating Entity Relationship Diagram in Visio
It is a common task for a developer to build an Entity Relationship
(ER) Diagram for an existing database. If you are dealing with an MS
SQL Server, this can be done easily within SQL Server Management Studio,
but what if you are given a database in MS Access, PostgreSQL, or
MySQL. There are tools (such as ModelRight) to help you with this, but
if you have got MS Visio Professional Edition, you have another option.
Since Visio 2003, a new feature, Reverse Engineer, has been made available in its Professional edition (and Premium edition in Visio 2010). This feature allows you to connect to an existing database, extract database schema, and create an ER Diagram automatically. You can also lay things out in the way that you want, and catch changes made to the database.
The key here is to create a connection to your database. It does not have to be a Microsoft database. Most likely, if there is an ODBC Data Source defined on your computer, you can connect to your database in Visio and generate the diagram. In the rest of this article, I will show you how to generate an ER Diagram for an existing Access Database using Visio 2010 Professional Edition. The process would be similar for connecting to other types of databases.
Since Visio 2003, a new feature, Reverse Engineer, has been made available in its Professional edition (and Premium edition in Visio 2010). This feature allows you to connect to an existing database, extract database schema, and create an ER Diagram automatically. You can also lay things out in the way that you want, and catch changes made to the database.
The key here is to create a connection to your database. It does not have to be a Microsoft database. Most likely, if there is an ODBC Data Source defined on your computer, you can connect to your database in Visio and generate the diagram. In the rest of this article, I will show you how to generate an ER Diagram for an existing Access Database using Visio 2010 Professional Edition. The process would be similar for connecting to other types of databases.
- Make sure you have an ODBC Data Source defined for MS Access Database. Usually, you do not have to do this for Access Database. It should have been created when Office or Visio is installed. For other types of databases, you may need to first install an ODBC Driver which is often available from your database provider.
- Start Visio, and choose Database Model Diagram Template under Software and Database Template Category. It is important to choose the right template, or you will not see the feature we want to use.
- Once the file is created, you will see two new things that you normally do not see. The Tables and Views window in the Task Pane, and the Database Tab in the Ribbon area. Please note that you will not see them, if you did not choose the right template in step #2.
- Click on the Reverse Engineer button under the Database Tab to start the Reverse Engineer Wizard.
- Select Microsoft Access in the Installed Visio drivers drop down list, and choose MS Access Database as the data source. (If you are connecting to another type of database, you may have to choose ODBC Generic Driver in this step.)
- Then you will be asked for user credential. Leave them blank if the database is not password protected. (This step may look different, if you are connecting to another type of database, but the wizard should lead you through the data source setup in a similar way.) Select your Access Database file and click OK to continue.
- You will be given the chance to select types of objects you want to pull from your database. Do all that and then click Next to continue.
- After everything is set, click Finish to close the wizard window.
- Visio will then connect to your database, and pull desired information back. Tables and Views will be placed in the Task Pane, and shapes and connections will be drawn on the current page (if you chose to do so in step #7).
- You can drag the entities around on the page without breaking the relationships, and click the Refresh button under the Database tab to get changes from the database. During the update, new Tables or Views will be added to the Task Pane, changes may be applied to the diagram, and everything else should be kept unchanged.
Thanks for the article. Any chance of updating the links to the figures, so the web diagrams show up?
ReplyDelete