Working with DataSet Objects in Visual Studio .NET

Chapter 7

Working with Relational Data

Database tables are rarely independent structures. If you look at the tables in the Microsoft SQL Server 2000 sample Northwind database, shown in Figure 7-1, you'll see that they're all interrelated. Notice that no table stands alone.

Figure 7-1

Relations between tables in the Northwind database

Not all databases have such a high percentage of related tables, but most contain tables that are related. When you build applications, you'll encounter scenarios in which you want to display or programmatically access data from related tables in your database.

When you're working with data from multiple DataTable objects, you're likely to need four types of features—those for navigation, validation, aggregation, and cascadation. OK, cascadation isn't really a word. But even though this is a technical book, I'm still entitled to a little artistic license once in a while.

Users will want to navigate between different tables of information to easily locate related rows, such as the orders for a particular customer. They'll want to validate their data to make sure that they don't create orphaned rows in the database. Applications will often require you to gather aggregate information—for example, to display the number of items in, and total cost of, an order. And when a parent row is modified, you might want the changes to cascade down to child rows—for example, if an order is deleted, you'll probably want the items associated with that order to be deleted as well.

In this chapter, we'll look at how to use the ADO.NET DataRelation object to work with data from related DataTable objects. I'll also discuss the features of the ForeignKeyConstraint object, which I introduced in the previous chapter, in more detail.



Microsoft ADO. NET Core Reference
Microsoft ADO.NET (Core Reference) (PRO-Developer)
ISBN: 0735614237
EAN: 2147483647
Year: 2002
Pages: 104
Authors: David Sceppa

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net