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.

What do you want to do?

Create a table in a database model diagram

Add a column to a table

Set a primary key

Remove a table

Show information about a table

Create a table in a database model diagram

  1. Open the database model diagram that you want to work with.

  2. From either the Entity Relationship or Object Relational stencil, drag an Entity shape onto the drawing.

  3. Double-click the shape to open the Database Properties window.

  4. Under Categories, click Definition and type a name for the table.

  5. Under Categories, click Columns and type a name and choose a data type.

  6. Select Req’d for columns that can't have null values.

  7. Select PK (primary key) for columns that uniquely identify each row in the database table.

  8. Under Categories click Indexes, Triggers, Check, or Extended to create these optional elements.

Tip: When you drag an entity shape onto the diagram is has a default name. To change the defaults, on the Database menu, point to Options, click Modeling, and go to the Logical Misc tab.

Top of Page

Add a column to a table

After you create a table, you need to add columns and define column properties, such as data type and primary keys.

  1. Double-click the table in your diagram.

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

  3. Click in the first empty Physical name cell and type a name.

  4. To change the data type for a column, click the column's Data Type field, and then select a data type from the list or type it into the list. For example, you could type decimal(8,2) or char(30).

  5. To prevent null values, select the Req'd check box.

  6. To specify that the column is a primary key, select the PK check box.

Top of Page

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.

  1. Double-click the table in your diagram.

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

  3. 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.

Note: Types cannot be used as primary keys.

Top of Page

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.

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

  2. 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.

Top of Page

Show information about a table

You can show information about tables in your diagram, such as primary keys (PK), foreign keys (FKn), Alternate Keys (AKn), unique (UN), and indexes (In), and data types.

  1. On the Database menu, point to Options, and then click Document.

  2. On the Tables tab choose the items that you want to display in the diagram.

    If you have your notation set to Relational, the annotations are displayed in the left column. If you are using IDEF1X, the annotations are within parentheses beside the column name.

Top of Page

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×