Share via


Relation Dialog Box

Allows you to create a relationship (a DataRelation object) that maintains information about parent-child records in two data tables in a dataset. You can use the relation object in code at run time to get child records for a specific parent record.

Creating a relationship also creates a foreign-key constraint that is added to the child table. A foreign-key constraint can implement referential integrity between parent and child tables.

This dialog box appears when you drag a Relation object from the DataSet tab of the Toolbox or when you select a relation line in a dataset and choose Edit Relation from the Data menu. You can only create a relation if there is more than one table defined in the dataset.

User Interface Element List

  • Name
    Allows you to name the relationship. For example, if you are relating a Customers table to an Orders table, you could name the relation CustomersOrders.

  • Parent table
    Specifies the table to act as parent table from the list of available tables in the dataset.

  • Child table
    Specifies the table to act as child table from the list of available tables in the dataset.

  • Key Columns
    Specifies the column or columns that constitute the primary key in the parent table. If the parent table has multiple columns that make up the key, select each part of the key in a separate row of the grid.

  • Foreign Key Columns
    Specifies the column or columns in the child table that form a foreign key pointing to the parent table. If the parent table has only one primary key column, select the column in the child table that corresponds to it. If the parent table has multiple columns that make up the key, select all the child columns that constitute parts of the parent-table key.

  • Both Relation and Foreign Key Constraint
    Creates both a relation and foreign key constraint (see below for descriptions).

  • Foreign Key Constraint Only
    A ForeignKeyConstraint restricts the action performed when a value in a column (or columns) is either deleted or updated.

  • Relation Only
    A DataRelation is used to relate two DataTable objects to each other through DataColumn objects.

  • Update rule
    Specifies how changes are made to child records when a parent record is updated to maintain referential integrity. For more information about the options you can select, see the Rule enumeration.

  • Delete rule
    Specifies how changes are made to child records when a parent record is deleted to maintain referential integrity. For more information about the options you can select, see the Rule enumeration.

  • Accept/Reject rule
    Specifies how changes are made to child records when changes to a parent record are accepted or rejected to maintain referential integrity. For more information about the options you can select, see the Rule enumeration.

  • Nested Relation
    Toggles the Nested property and controls how this relationship is rendered as XML. For more information, see Nesting DataRelations (ADO.NET).

See Also

Tasks

How to: Access Records in Related DataTables

How to: Create DataRelations with the Dataset Designer

Concepts

Displaying Data Overview

Reference

DataRelation

Other Resources

Connecting to Data in Visual Studio

Preparing Your Application to Receive Data

Fetching Data into Your Application

Displaying Data on Forms in Windows Applications

Editing Data in Your Application

Validating Data