# DataSet Definition

A DataSet is a data container composed of tables (DataTables) that contain rows (DataRows), uses SQL queries to retrieve that data from the database, tracks changes to each columns and generated update/insert/delete statements transparently when required to write data back into the database.

Each DataRow may have one of the following RowStates:

* **New**: the row was added to the dataSet and will be ignored on Save
*

    **EditingNew**: the row was already edited and it’s prepared to be saved
*

    **Modified**: an existing row was modified
*

    **NotModified**: an existing row was retrieved from the database
*

    **Deleted**: the row was marked as deleted, will be deleted only at Save
*

    **None**: the row was not added to the collection; the row is detached

For updateable DataSets, the tables must be arranged in the same order, in which the primary-key inserts are done.

For the Delete operation, the DataSet will do the action in the reverse order.

![Update/Delete Order](https://2522353545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXf5GuikRIHooatf_sm%2F-MXfOUims_Op19QU0aOQ%2F-MXfT2rs_LRyBxN7Qx1y%2Fdataset_editor_1.png?alt=media\&token=708ab99b-72c8-40f0-8ae8-d896465be469)

Reordering can be done on the second tab (Tables) of the DataSet-Editor (shortcut **TDS**), using Drag\&Drop.

![](https://2522353545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXf5GuikRIHooatf_sm%2F-MXfOUims_Op19QU0aOQ%2F-MXfTiNrft9o4v2UklD7%2Fdataset_editor_2.png?alt=media\&token=1cde9dbe-29a5-4ede-869d-b8a3af8d41ce)



