How to: Create Relationships Between Tables on a Diagram (Visual Database Tools)

New: 17 July 2006

You can create relationships between columns in different tables in the Diagram Designer by dragging columns between tables. For more information about relationships, see Types of Table Relationships (Visual Database Tools).

To create a relationship graphically

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

  2. Drag the selected column(s) 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 may 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.

See Also

Other Resources

Tables and Columns Dialog Box (Visual Database Tools)
Foreign Key Relationships Dialog Box (Visual Database Tools)
Working with Relationships (Visual Database Tools)
Working with Constraints (Visual Database Tools)
Working with Indexes (Visual Database Tools)
Working with Tables in Database Diagram (Visual Database Tools)

Help and Information

Getting SQL Server 2005 Assistance