How to create a many-to-many relationship between tables (Enterprise Manager)

How to Install SQL Server 2000

How To

How to create a many-to-many relationship between tables (Enterprise Manager)

To create a many-to-many relationship between tables

  1. Open a database diagram.

  2. Add the tables that you want to create a many-to-many relationship between.

  3. Create a third table by right-clicking within the database diagram, and then clicking New Table.

    This will become the junction table.

  4. In the Choose Name dialog box, enter a name for the table.

    For example, the junction table between the titles table and the authors table is named titleauthors.

  5. Copy the primary key columns from each of the other two tables to the junction table.

    You can add other columns to this table, just as you can to any other table.

  6. In the junction table, set the primary key to include all the primary key columns from the other two tables.

  7. Define a one-to-many relationship between each of the two primary tables and the junction table.

See Also

Adding Tables to a Diagram

Copying Columns from One Table to Another

Mapping Many-to-Many Relationships to a Database Diagram