Tuesday, 13 August 2013

About DataSet in ADO.NET

Short note on: DataSet.-OR- Expain Dataset?

Dataset object is centralized to ADO.NET architecture to support disconnected and distributed data scenarios.

Dataset object is used to manage the data of Data Source locally.

Dataset can be used with the multiple and different data sources or even with the XML data also.

Dataset represents the complete set of related data, constraints and the relationship among tables just like Data Source have.

Dataset Provides same representation of data regardless of Data Source and provides consistent relational programming model of Data Source.

It can be considered as a local copy of the some portions of the database.

The DataSet contains a collection of one of more DataTable objects made up of rows and columns of data.

Tables can be identified in DataSet using DataTable’s Tables property.

The DataSet is not connected to a data source after it is populated.

Dataset has two components:

  • DataTableCollection
  • DataRelationCollection
  1. DataTableCollection

    DataTableCollection contains all the DataTable objects in a Dataset.

    A DataTable is defined in the “System.Data” namespace.

    DataTable provides representation of single table inside DataTableCollection.

    DataTable contains the collection of,

    • Row
    • Column
    • Constraint

    Collection of row represented by the DataRowCollection.

    Collection of column represented by the DataColumnCollection.

    Collection of constraint represented by the ConstraintCollection.

    Column and Constraint collection represents the schema of the table.

  2. DataRelationCollection

    A relationship associates rows in one DataTable with the rows in other DataTable.

    A relationship is represented by the DataRelation objects.

    A relationship is a join path between Primary Key and ForeignKey columns in a relational database.

    DataRelation identifies matching columns in two tables of a Dataset.

    Relationship enables navigation from one DataTable to other DataTable in Dataset.

    The elements of DataRelation are,

    • Name of the relationship
    • Name of the tables being related
    • Related column in each table

    Relationship can be built with more than one column per table. You can do it by specifying an array of DataColumn objects as key columns.

    When you add a relationship to DataRelationCollection, you can optionally add a UniqueKey Constraint and a ForeignKey Constraint to enforce integrity constraints when changes are made to related column values.

No comments:

Post a Comment