Building Queries and Data Views
|
Designing a Query
The first step in constructing a query (or, more often, a set of queries) is a design step—drawing on the requirements identified to answer the following questions critical to the query design:
- What types of data sources do I need to query?
- What is the structure of each data source; that is, what do the XML source schemas look like?
- What do I want the query result (that is, the output of the query) to look like? In other words, how do I want to structure the output?
- What should the target XML schema look like? (The target schema defines the structure of the query result.)
- What target schema design pattern should I use?
Note: Proper design of the target schema is a key factor in building a successful query. In a nutshell, you need to ensure that cardinality is correct and check for target conformity. For complete guidelines and examples of recommended design patterns, see Target Schema Design Guidelines and Query Examples.
- What source conditions do I need to define to get the information I need from the data sources? (Source conditions are joins, unions, aggregations and so on defined to filter the source data in a certain way.)
Once you have designed or "modeled" the query in this way based on what you want the query to do and defined an outline strategy for accomplishing the information filtering, you are ready to build a test version of the query. For other than very simple queries, you will probably revise, refine and test the query several times adding optimization if necessary.