Database Reference
In-Depth Information
Figure 11-19
the aDO.NEt DataSet
Object Model
DataSet
DataRelationCollection
DataRelation
Extended Properties
DataTableCollection
DataTable
DataRowCollection
DataRow
Constraints
Constraint
DataColumnCollection
DataColumn
PrimaryKey
ExtendedProperties
ChildRelations
ParentRelations
Extended Properties
DataView
proposed values . Each DataTable object has a PrimaryKey property to enforce row unique-
ness. The Constraints collection uses two constraints. The ForeignKeyConstraint supports
referential integrity, and the UniqueConstraint supports data integrity.
The DataRelationCollection stores DataRelations , which act as the relational links
between tables. Note again that referential integrity is maintained by the ForeignKeyConstraint
in the Constraints collection. Relationships among DataSet tables can be processed just as rela-
tionships in a database can be processed. A relationship can be used to compute the values of a
column, and DataSet tables can also have views.
The ADO.NET Command object shown in Figures 11-17 and 11-18 is used as an SQL state-
ment or stored procedure and is run on data in the DataSet. The ADO.NET DataAdapter object is
the link between a Connection object and a DataSet object. The DataAdapter uses four Command
objects: the SelectCommand object , the InsertCommand object , the UpdateCommand object ,
and the DeleteCommand object . The SelectCommand object gets data from a DBMS and places
it in a DataSet. The other commands send changes in the DataSet back to the DBMS data.
The ADO.NET DataReader is similar to a cursor that provides read-only, forward-only data
transfers from a data source and can only be used through an Execute method of a Command.
Looking ahead to our discussion of XML later in this chapter, we see some advantages
of ADO.NET over ADO. Once a DataSet is constructed, its contents can be formatted as an
XML document with a single command. Similarly, an XML Schema document for the DataSet
can also be produced with a single command. This process works in reverse as well. An XML
Schema document can be used to create the structure of a DataSet, and the DataSet data can
then be filled by reading an XML document.
By ThE WAy You may be wondering, “Why is all of this necessary? Why do we need an
in-memory database?” The answer lies in database views like that shown
in the XML section of this chapter in Figure 11-61. There is no standardized way to
 
 
Search WWH ::




Custom Search