The Evolution of Query Layers

4430
1
04-08-2014 03:04 AM
MelissaJarman
Esri Contributor
1 1 4,430
Query layers were first introduced at the 10.0 release primarily to allow ArcMap to integrate data from databases that do not contain the system geodatabase repository tables. Think of query layers as a method for accessing database objects that are not geodatabase-aware, without having to go through the process of registering the objects with ArcSDE or the geodatabase.

When first released, the only way to create a query layer was in ArcMap using the Add Query Layer tool, which also required a special connection file (.qcf). This file was required for ArcGIS to connect to databases that did not have a geodatabase component. Native access to both spatial and non-spatial database objects through the ArcGIS client application allowed for the ability to integrate a wider spectrum of data into GIS projects, and provided the ability for modification to include a specific subset of data – similar to a definition query and/or a database view.

With the ArcGIS 10.1 release, new functionality was added to make database connections native in ArcGIS, which eliminated the need to create the query connection file (.qcf) when building query layers. Query layers evolved from something that could only be manually built to a behavior that automatically occurs when accessing database objects that are not geodatabase-aware through a database connection file (.sde) in ArcGIS. In other words, query layers are generated dynamically by adding non-geodatabase objects to ArcMap via drag and drop from the Catalog window.What is a query layer?

Are query layers read-only?


Query layers are read only in ArcMap. At the 10.1 release, ArcGIS Spatial Data Server (SDS) services were introduced, which allowed the publishing of database data in an editable feature service. At 10.2, ArcGIS for Server feature access enabled map services were enhanced to allow data to be published from database connections that didn’t contain the geodatabase system tables. This opened up the ability to edit query layers via an ArcGIS for Server feature service and eliminated the need for the ArcGIS Spatial Data Server (SDS).Ability to edit query layers:
VersionEditable?
10.0No
10.1Yes – via SDS service
10.2Yes – via feature access enabled map service

To edit the data at 10.1, create a map that contains your database data, and publish that data to the ArcGIS Spatial Data Server service.

NOTE: To publish editable feature services via SDS, ensure the layer is not contained within a geodatabase.

Beginning with ArcGIS 10.2, you should use ArcGIS for Server feature services to publish data from supported database management systems. This allows you to edit query layers via the feature access enabled map services, and takes the place of ArcGIS Spatial Data Server feature services (which have been deprecated). These workflows are intended for databases that do not have the geodatabase system repository tables populated; I like to call these NON-geodatabases.

NOTE: When authoring feature services using enterprise or workgroup geodatabases, all data must be registered with the geodatabase. This means that if you have query layers or spatial tables contained within a geodatabase that are not registed with the geodatabase, you will experience errors in analyzing when preparing to publish. Your options are:
  • Register the spatial tables or query layers within the existing geodatabase, creating feature classes
  • Publish the feature service from a NON-geodatabase (a database that is not enabled with the system repository tables)
  • Publish query layers from a map service and overlay these with feature service layers in a web map

Database views are not supported for publishing via feature services within a geodatabase because they cannot be registered with the geodatabase.

How to create a query layer


A query layer can be created manually in ArcMap by building a query against objects that exist within a geodatabase or a database that does not contain the geodatabase system repository tables. You should use this method to create a query layer if you need to define a subset of data. For example, when working with a layer that contains a large number of features, you should use the Add Query Layer tool and include a 'where' clause that restricts the number of features that will be included in the query layer.
  • Build a Query Layer manually using the ‘New Query Layer’ dialog in ArcMap: File > Add Data > Add Query Layer

A query layer is created when the layer/table that is not registered with the geodatabase is added to ArcMap via these additional methods:
  • Starting at 10.1 - Drag and drop a database layer into ArcMap from ArcCatalog or the Catalog window in ArcMap –The ArcMap Layer properties will display a Data Type of ‘Query Feature Class’ within the source tab
  • Using the Add Data button within ArcMap to add data from a database
Creating a query layer

Display behavior of database data in ArcGIS

ArcGIS for Desktop reads the layers in a database that contain feature geometry and displays them within ArcCatalog. How these appear in the Catalog tree changed starting at the 10.1 release. When data is viewed in ArcCatalog or the Catalog window in ArcMap, a new icon is displayed. MJarman02-Icon1.pngThis icon indicates that the object is a non-geodatabase aware/registered table with a spatial component/column.
  • Dragging a database layer with this icon into ArcMap would create a query layer where the feature geometry is discovered and rendered.
  • Double-clicking this object within ArcCatalog will discover and change the icon to a feature class icon for the specific geometry type that is stored in the geometry column.
MJarman03-Icon2.jpg
  • Within ArcMap the layer will display similarly to a feature class, but checking the layer properties source within ArcMap reveals the Data Type of Query Feature Class.
MJarman01-Layerproperties.pngViewing database data in ArcGIS

SUMMARY


Important things to note about query layers:
- Query layers only persist within the map document that they were created in
- Query layers do not require a geodatabase
- Query layers are read-only in ArcMap when added directly from a database connection
- Currently, query layers are only editable when accessed via certain types of services and datasources:
  • 10.1 – Spatial Data Server feature access enabled services can edit query layers
    • This functionality only existed for one product release as it was incorporated into the feature access enabled map service at the 10.2 release
  • 10.2 – Query layers can be edited as part of a feature enabled map service published from databases (not enabled with the geodatabase system repository tables)

- .qcf files are query connection files that were generated for the 10.0 release to allow the connection to a non-geodatabase-aware relational database to build a query layer. Starting at the 10.1 release these were no longer needed, but continued to work.

Additional References:

What's new for geodatabases in ArcGIS 10 > Data management in geodatabasesWhat's new at 10.2 - See ‘Publishing feature services from databases’FAQ:  What has changed in Query Layers between ArcGIS 10.0 and 10.1?Melissa J. - Technical Lead, Geodata Team
1 Comment
About the Author
Product Engineer - Geodatabase Team