Add tables and columns to Database Model diagrams

Tables in a database model diagram represent the structure of a table in a database, including the table name, column names, primary keys, and data types. Using the Database Model Diagram template, you can create new tables, change existing tables, or reverse engineer tables from an existing database.

Can't find the database modeling features?

It is most likely that your edition of Microsoft Office Visio doesn't include the features you are looking for. To find out which edition of Visio you have, click About Microsoft Office Visio on the Help menu. The name of the edition is in the top line of text in the dialog box.

Microsoft Office Visio Standard does not include the Database Model Diagram template.

Microsoft Office Visio Professional supports the reverse engineering features for the Database Model Diagram template (that is, using an existing database to create a model in Visio) but it does not support forward engineering (that is, using a Visio database model to generate SQL code).

Note: You can find the full suite of database modeling features, including both reverse engineering and forward engineering, in Visio for Enterprise Architects. Visio for Enterprise Architects is included in MSDN Premium Subscription, which is available with Visual Studio Professional and Visual Studio Team System role-based editions.

Set a primary key

Relationships use primary and foreign keys to map rows in one table to corresponding rows in another table. At least one of the tables in the relationship must have a primary key in order to establish a relationship.

Double-click the table in your diagram.

In the Database Properties window, under Categories, click Columns.

Select the PK box for the column for which you want to use a primary key. You can select more than one check box if you want to create a composite key.

Remove a table

When you remove a table from a database model diagram, you can either remove the table from only the diagram, or from both the diagram and the underlying model. It can be helpful to remove tables from only the diagram while you are trying out scenarios.

Click the table in your model and press the DELETE key on your keyboard.

In the Delete Object dialog box do one of the following:

Click Yes to remove the table from both the drawing and the underlying model.

Click No to remove the table only from the drawing.

Note: If you click No and later decide to add the table back into the drawing, you can drag it onto the drawing from the Tables and Views window.

Tip: You can choose to always or never remove deleted relationships from the underlying model. On the Database menu, point to Options, click Modeling, and on the Logical diagram tab select the option that you want.