Edit

Share via


Create relationships between tables on a diagram (Visual Database Tools)

Applies to: SQL Server

You can create relationships between columns in different tables in the Diagram Designer by dragging columns between tables.

Create a relationship graphically

  1. In Database Designer, select the row selector for one or more database columns that you want to relate to a column in another table.

  2. Drag the selected columns to the related table.

  3. Two dialog boxes appear: Foreign Key Relationship and Tables and Columns, with the latter appearing in the foreground.

  4. Relationship name has a system-provided name in the format FK_localtable_foreigntable. You might change this value.

  5. Verify that Primary key table specifies the correct table.

  6. The grid lists the local columns and their matching foreign columns. You can add or remove table columns or change mappings.

  7. Choose OK.

    The Foreign Key Relationship dialog box appears. Selected Relationship shows the relationship you have created.

  8. Change properties for the relationship in the grid.

  9. Choose OK to create the relationship.

    Database Designer shows a relationship between the columns you chose.