Skip navigation.

Building Queries and Data Views

  Previous Next vertical dots separating previous/next from contents/index/pdf Contents Index View as PDF   Get Adobe Reader

Introduction

This section introduces the Data View Builder, a programming tool you can use to plan, design, build, and test queries using BEA Liquid Data for WebLogic.

The following topics are covered:

The Liquid Data Data View Builder is a major component in an end-to-end query development and testing system. The Data View Builder is ideal for trying out and refining queries in relationship to target XML schemas, or more usually referred to as target schemas, that provide additional, needed instructions as to how the results of your query should be represented.

For the complete overview of the Liquid Data system see the Concepts Guide.

 


Data View Builder Overview

The Data View Builder is a GUI-based tool for designing and generating target schemas and XQueries (in W3C XQuery syntax). You can then run the queries against multiple diverse data sources to retrieve and consolidate data. The Data View Builder provides a graphical, drag-and-drop mapping approach to query design and construction. You can use it to free yourself from having to manage the intricacies of query languages such as SQL while allowing you to give full attention to:

Benefits of the Data View Builder

The Data View Builder lets you create queries using an intuitive, drag-and-drop mapping strategy. The XML schema representations and mappings of source and target data are packaged and saved as a project. Using Liquid Data projects you can retrieve the full picture of the query, complete with source schemas and target mappings. Queries can also be stored as data views that can be treated as data sources themselves in Liquid Data and re-used.

How the Data View Builder Works

Once a data source has been configured in Liquid Data using the Liquid Data node of the WebLogic Administration Console (see the Liquid Data Administration Guide), it becomes available to the Data View Builder. The structure of the data stored in relational databases, Web services, application views, data views, delimited files, and XML files themselves are all represented as XML schemas.

Figure 1-1 Sample Relational and XML Source Schema

Sample Relational and XML Source Schema


 

By representing disparate data sources as XML schemas, Data View Builder makes it easy for you to represent relationships among different types of data sources.

To build up your query you simply drag and drop elements and attributes among XML schema representations of data sources to create joins, unions, and so on. The default source condition is a join. It uses a built-in equality [eq] function; more complex XQuery functions are also available.

You can also map elements from source schemas to a target schema to shape the structure of the query. Target schemas can be created "on the fly" from existing data source representations or created externally. Optimization hints can be added to queries to improve query performance.

Queries can be automatically generated at any point in the development process. When you run the query the underlying data sources are accessed and the results appear in tree-view or XML. The query can also be deployed for use in BEA WebLogic Workshop web applications, among other technologies.

 


Key Concepts of Query Building

The following terms and concepts are introduced here:

Data Sources

Liquid Data supports multiple types of data sources in addition to RDBMS (relational database management systems) including:

See Data Sources, for a complete survey.

Source and Target Schemas

XML schemas are used in Liquid Data to describe the hierarchical structure of the various data sets. The Data View Builder uses XML schema representations as follows:

Liquid Data queries require identified data sources. Each data source requires an associated schema. For relational databases, the schema is automatically created based on the metadata available through the database JDBC driver. For XML files, Views, Complex Parameter Types, Stored Procedures, or Web Services, you specify the schema when you define the data source to Liquid Data.

For more information on source and target schemas in Liquid Data, see Source and Target Schemas.

Queries and Query Joins, Unions, Aggregates, and Functions

A query can be thought of as a way of filtering through large amounts of data or information to extract only the specifics relevant to a particular problem.

A number of tools and techniques are available to develop or expand business logic around the data base schemas. These tools and techniques include:

Joins

A query with a join operation combines information in two data source schemas when there is a match on a common field.

For example, you could specify first and last names of all customers in two data sources — BroadBand and Wireless — and they use a join to limit the output (query result described by the target schema) to the subset of those customers with matching customer IDs in both source schemas.

Unions

Union operations enable you to combine data from multiple sources into a single set of results described by the structure of the target schema. Even though the content of the source schemas can be the same, or different, you can use a union type query to consolidate elements in source schemas into a tailored view of the data. For example, you could construct a query that reports all customer orders from multiple sources into a single result. This is a very typical use of Liquid Data target schemas.

XQuery Functions

Liquid Data provides a large number of XQuery functions. These built-in functions can by used by any Liquid Data query.

Aggregates

You can create queries in Liquid Data that aggregate query results, providing summary information on a set of data. Typical aggregate functions are average [avg], count, maximum [max], minimum [min], and sum. You can use aggregate operations to perform various business calculations such as finding the total number of customers, calculating purchases by a single customer, calculating the average salary of workers, and so on.

Other Built-in Functions

All conditions are set through functions. The default function for a simple equality function [eq[. If you drag and drop one data source element onto another you have created a simple join using the equals function with two parameters (the two data source elements) which gets expressed as value1 eq value2 in the Data View Builder-generated XQuery.

For information on W3C standard functions supported by Liquid Data, see Functions Reference in the XQuery Reference Guide.

You can also create and use custom functions. See Configuring Access to Custom Functions in the Liquid Data Administration Guide.

Query Parameters

There are two types of query parameters:

Constants

Although not as flexible as query parameters, numeric and string constants are easily created and used.

Stored Queries

A stored query is a query that has been saved to the stored_queries folder Liquid Data repository. Queries must be saved with a .xq extension to be recognized as stored queries in Liquid Data.

The query result for a stored query can be cached.

Caching of query results for stored queries is configurable through the Liquid Data node of the WebLogic Administration Console (see Configuring the Query Results Cache in the Liquid Data Administration Guide). Using this feature, you can specify whether or not to cache query results for stored queries.

Ad Hoc Queries

An ad hoc query is a query that has not been stored in the Liquid Data repository, but rather is passed to the Liquid Data server at run time.

Query Plans

A query plan is a compiled query. Before a query is run, Liquid Data compiles the XQuery into an optimized query plan. Optionally, you can compile the query plan without running the query.

At runtime, Liquid Data executes the query plan against physical data sources and returns the query results.

 


How This Book is Organized

Building Queries and Data Views can be thought of as having several sections:

Focus

Chapters

Introduction

Query Components

Query Design

Special Data Sources

This book does assume some familiarity with the purpose and operation of the Liquid Data graphical query development tool called Data View Builder. You can familiarize yourself with this tool in several ways:

 


Next Steps

 

Skip navigation bar  Back to Top Previous Next