Adding Tables

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.  Alternatively, you can create a table or modify an existing table with the Table Designer.

Creating a New Table with Table Designer

Using Table Designer, you can create a new table in the database without opening a database diagram.

To create a new table with Table Designer

  1. Make sure you are connected to the database in which you want to create the table. Right-click the Tables node of the target database and choose New Table.

  2. Add the columns and other details of the table.

Note   For each column you add, a new row appears in the top portion of the Table Designer.  Within that row, you can edit the column's basic properties.  To edit the columns other properties, you can use the bottom portion of the Table Designer.  Simply click on a particular row in the top portion of the Table Designer, then add or edit the values for the properties appearing in the bottom portion.

Inserting a New Table

Adding a new table to the database diagram means that you are defining a new table that does not already exist in the database. To create a new table, you must define the individual columns that make up the table. The table is created in the database when you save the table or the diagram.

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.


Right-click in the diagram and select New Table.

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

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

  3. Under Datatype, select a data type for the column. Each column must have a name and data type.
    You can set the column's other properties, such as Scale, by using the Columns property page.  See Setting Column Properties for details.

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

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

Note   If you create a new table, then remove it from the diagram before saving it to the database, the table name remains in memory until you close the database diagram. Also, if you delete an existing table from the database, the table name remains in memory. To use the table name again, close and restart the Database Designer.

Adding an Existing Table

Adding an existing table means that the table you want to appear in your diagram already exists in your database. If you add a group of tables to a diagram, any relationships that exist between the tables are also added to the diagram.

To add an existing table to a diagram

  1. Open a database diagram.

  2. Right-click inside the diagram, then choose Add Table....

  3. In the Add Table dialog box, click the table, then click Add.  Alternatively, you can double-click any tables you want to add before closing the dialog box.

  4. Click Close to close the Add Table dialog box.

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

When you add a table to a diagram, the definition of the table (not the data that is stored in the table) is loaded from your database into memory. At that point you can edit the table's definition. For example, you can add new columns or modify its indexes, key, relationships, or constraints.

Adding Related Tables

For tables with existing foreign key constraints, you can easily add the related tables to the database diagram.

To add related tables to a diagram

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

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

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

Copying a Table Across Database Diagrams | Deleting a Table from a Database Diagram and the Database | Removing a Table from a Database Diagram | Renaming a Table | Tables