Bagikan melalui


Foreign Key Column Properties

These properties show which table and primary or unique key are related to the selected foreign key.

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 Visual Studio Settings.

Properties for object selected in Server Explorer

  • Identity Category
    Expands to show the name property.

  • Name
    Shows the name of the foreign key relationship.

  • Misc Category
    Expands to show remaining properties.

  • Referenced Key
    Shows the name of the primary or unique key on the primary side of the relationship.

  • Referenced Table
    Shows the name of the table of the referenced key.

Properties for object selected from the Properties window dropdown

  • General Category
    Expands to show Check Existing Data on Creation or RE-Enabling and Tables and Columns Specifications.

  • Check Existing Data on Creation or Re-Enabling
    Indicates whether all data that exist in the table before the constraint was created or re-enabled is verified against the constraint.

  • Tables and Columns Specifications Category
    Expands to show which columns from which tables act as the foreign key and primary (or unique) key in the relationship. To edit or define these values, click the ellipsis (…) to the right of the property field.

  • Foreign Key Base Table
    Shows which table contains the column acting as a foreign key in the selected relationship.

  • Foreign Key Columns
    Shows which column acts as a foreign key in the selected relationship.

  • Primary/Unique Key Base Table
    Shows which table contains the column acting as a primary (or unique) key in the selected relationship.

  • Primary/Unique Key Columns
    Shows which column acts as a primary (or unique) key in the selected relationship.

  • Identity Category
    Expands to show the property fields for Name and Description.

  • Name
    Shows the name of the relationship. When a new relationship is created, it is given a default name based on the table in the active window in Table Designer. You can change the name at any time.

  • Description
    Provides a place to describe the relationship. To write a more detailed description, click Description and then click the ellipsis (...) that appears to the right of the property field. This provides a larger area in which to write text.

  • Table Designer Category
    Expands to show information for Check Existing Data on Creation or Re-Enabling and Enforce for Replication.

  • Enforce for Replication
    Indicates whether the constraint is enforced when the table is replicated into a different database.

  • Enforce Foreign Key Constraint
    Indicates whether changes to the data of the columns in the relationship are allowed if those changes would invalidate the integrity of the foreign key relationship. Choose Yes if you do not want to allow such changes and choose No if you do want to allow them.

  • INSERT and UPDATE Specification Category
    Expands to show information for the Delete Rule and the Update Rule for the relationship.

  • Delete Rule
    Specifies what happens if an end user of the database tries to delete a row with data that is involved in a foreign key relationship. If set to:

    • No Action   An error message tells the user that the deletion is not allowed and the DELETE is rolled back.

    • Cascade   Deletes all rows containing data involved in the foreign key relationship.

    • Set Null   Sets the value to null if all foreign key columns for the table can accept null values. Applies only to SQL Server 2005 and SQL Server 2008.

    • Set Default   Sets the value to the default value defined for the column if all foreign key columns for the table have defaults defined for them. Applies only to SQL Server 2005 and SQL Server 2008.

  • Update Rule
    Specifies what happens if a user of the database tries to update a row with data that is involved in a foreign key relationship. If set to:

    • No Action   An error message tells the user that the deletion is not allowed and the DELETE is rolled back.

    • Cascade   Deletes all rows containing data involved in the foreign key relationship.

    • Set Null   Sets the value to null if all foreign key columns for the table can accept null values. Applies only to SQL Server 2005 and SQL Server 2008.

    • Set Default   Sets the value to the default value defined for the column if all foreign key columns for the table have defaults defined for them. Applies only to SQL Server 2005 and SQL Server 2008.

See Also

Other Resources

Working with Keys

Working with Relationships