Compartir a través de


How to: Add Tables to Diagrams

You can add a table to your database diagram to edit its structure or relate it to other tables in your diagram. You can either add existing database tables to a diagram or insert a new table that has not yet been defined in the database.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Customizing Development Settings in Visual Studio.

To insert a new table into a diagram

  1. Make sure you are connected to the database in which you want to create the table.

    To create a table in your current diagram, click the New Table button on the toolbar.

    –or–

    Right-click in the diagram and select New Table.

  2. Modify or accept the system-assigned table name, in the Choose Name dialog box, and then choose OK.

    A new table appears in the diagram in Standard view.

  3. In the first cell of the new table, type a column name. Then press the TAB key to move to the next cell.

  4. Under Data Type, select a data type for the column. Each column must have a name and data type.

    You can set the column's other properties in Table Designer. For more information see Modifying Columns (Visual Database Tools).

  5. Repeat steps 3 and 4 for each column you want to add to the table.

Note

When you save your database diagram, the new table will be added to your database.

To add an existing table to a diagram

  1. Make sure you are connected to the database whose tables you want to edit.

  2. Select a table in the Tables folder.

  3. Drag the table into your database diagram.

  4. Release the mouse button.

Note

If relationships exist between the selected table and other tables in your diagram, relationship lines are automatically drawn.

  1. Select one or more tables with foreign key constraints in the database diagram.

  2. Right-click any of the selected tables and choose Add Related Tables.

Note

Both those tables referenced by a foreign key constraint from the selected table(s) and those referencing the selected table(s) with a foreign key constraint are added to the diagram.

See Also

Other Resources

Working with Database Diagrams

Working with Tables in Table Designer