This documentation is archived and is not being maintained.

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 are using the Properties window to edit an untyped dataset, open the Relations collection, and add a new relation. You can only create a relation if there is more than one table defined in the dataset.

Note   To add relationships in typed datasets, you should edit the dataset schema. For more information, see Creating DataRelation Objects with the XML Designer.
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.
Parent 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.
Child 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.
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.

See Also

DataRelation Class | Navigating a Relationship between Tables | Introduction to DataRelation Objects | Dataset Updates in Visual Studio .NET

Show: