Friday, 24 April 2009

Using the Data Query view in FDO Toolbox (part 1)

Despite all of my posts talking about new FDO Toolbox releases and its new features, I haven't actually explained these features in more intricate detail. So this is going to be the first (of many) posts covering particular features of FDO Toolbox in more detail.

We're going to start with the Data Query view. For reference, these features are explained using the current version of FDO Toolbox (0.7.5)

The Data Query view allows you to preview any FDO data source in two ways:
  • Table (attribute) view
  • Map (spatial) view
To launch the Data Query view, right click a schema object or a class object of an open connection in the Object Explorer, and choose Data Query

This will launch the Data Query view as seen below.


1. This is the query mode selector, depending on the level of support from the provider, you can choose any of the following modes of query:
  • Standard. The standard method of querying feature data.
  • Aggregate. This is the standard method, with the ability to include aggregate expressions as part of the query result.
  • SQL. This allows you to issue SQL queries directly.
2. This is the user interface for the selected query mode. This is explained in more detail below.
3. This is the query result pane, with two tabs.
  • Grid View. This allows you to view your query results in a standard data grid format.
  • Map View: This allows you to view your query results as a set of rendered features on an empty map. Map View is only avaiable in standard query mode, and only if the selected class being queried is a Feature Class
4. This button executes the query with the specified parameters. You will get a warning about large result sets if you exceed the data preview limit. This limit is defined in the user preferences, which you can change by going to Tools and choosing Preferences

5. This button will cancel the currently executing query. Any queried results will be displayed on the result pane.

6. This button will clear the result pane

7. This button will allow you to save the query result into another FDO flat-file data source. See Saving Query Results for more information.

8. This button will allow you to insert a new feature into the specified feature class. This will be explained in greater detail in part 2.

Standard Query View

The standard query view looks like the following:

  1. Indicates the current feature schema
  2. Indicates the class to be queried. If this class is not a feature class, the Map Preview will not be available
  3. Indicates the filter to apply to the query, clicking this field will launch the Expression Editor that can assist in building the filter (will be covered in a future post)
  4. Indicates the maximum number of results to return.
  5. Indicates the class properties to return as part of the query result set.
  6. Indicates any additional computed properties to return as part of the result set. This also uses the Expression Editor to define the computed properties.

Aggregate Query View

The aggregate query view is the same as the standard query view with the following additonal features


  1. Indicates whether to return a distinct set of the specified class properties.
  2. Allows you to specify grouping criteria and the group filter to apply.
SQL Query View

The SQL query view is the simplest interface of them all


  1. Allows you to enter the SQL query command.
This interface does not do any validation of the SQL query, that is handled by the underlying FDO provider. Any errors will be propagated back up to this interface and displayed in a message box.

Query Results (Grid View)

When you have executed your query you will get a table of data in your result pane like the following screen below:


The grid is read-only, none of the cells are editable. However, you can update or delete certain rows in this result set, by right clicking the row and selecting Update this feature or Delete this feature (as shown in the above screenshot). These updates and deletes will be sent back to the data source as IDelete and IUpdate FDO commands. This will be explained in part 2 in greater detail.

Query Results (Map View)

If the map view is supported, you can "visually" see the query result set. For example, the above query would look like the following.



The map view provides a standard set of toolbar commands to zoom and navigate the query result set.

Saving Query Results

One of the neat things you can do the the query result is to save it to another FDO flat-file data source. The Save toolbar button shows the available file formats the query result can be saved as. Currently the supported FDO providers are SDF and SQLite.

When saving the query result, it will also copy and apply the spatial context used by the selected feature class. This way both the queried data source and the saved query result will have the same spatial context information.

This feature is only available in Standard Query mode because it is the only mode where FDO Toolbox can interrogate the structure of the query result. There are plans to support this for SQL-based commands. When that arrives in FDO proper, expect support for it in FDO Toolbox.

Stay tuned for part 2, which will cover the CRUD (Create, Read, Update, Delete) functionality in greater detail.

No comments: