Hierarchical Update

Hierarchical update refers to the process of saving updated data (from a dataset with two or more related tables) back to a database while maintaining referential integrity rules. Referential integrity refers to the consistency rules provided by the constraints in a database that control the behavior of Inserting, Updating, and Deleting related records. For example, it is referential integrity that enforces the creation of a customer record before allowing orders to be created for that customer.

Saving modified data from related data tables is a little more complex than saving data from a single table. This is because the Update, Insert, and Delete commands for each related table have to be executed in a specific order to avoid violating referential integrity constraints. For example, consider an order entry application with which you can manage both new and existing customers and orders. If you have to delete an existing customer, you must first delete all of that customer's orders before deleting the customer record. If you are adding a new customer (with an order), you must first insert the new customer record before inserting that customer's orders because of the foreign key constraints that exist in the tables. As these examples show, you have to extract specific subsets of data and send the updates (Inserts, Updates, and Deletes) in the correct order to maintain referential integrity.

The hierarchical update feature uses a TableAdapterManager to manage the TableAdapters in a typed dataset. The TableAdapterManager component is a Visual Studio—generated component, so it is not part of the .NET Framework. For detailed information about the TableAdapterManager class, see the TableAdapterManager Reference section of TableAdapterManager Overview.

If your application uses typed datasets and gives users the ability to modify the data in related data tables (data tables in a one-to-many relationship such as Customers and Orders), you will probably want to use hierarchical update.

In This Section




N-Tier Data Applications

Saving Data

Dataset Designer


DataSets, DataTables, and DataViews (ADO.NET)

DataTables (ADO.NET)

Accessing Data (Visual Studio)