bea.com | products | dev2dev | support | askBEA

Download Docs | Site Map | Glossary
Search

Product Overview

Liquid Data Concepts

This section provides an overview of core BEA Liquid Data for WebLogicTM concepts and also some usage information. It contains the following sections:

- Liquid Data Implements the XQuery Standard

- Definitions of Key Terms

For an overview of Liquid Data components, see Liquid Data Architecture.

Liquid Data Implements the XQuery Standard

This topic describes XQuery and how Liquid Data implements the XQuery standard. It contains the following sections:

- About XQuery

- XQuery Links

- XQuery Example

Liquid Data provides a scalable, highly available platform for building and processing XQuery queries. Data Architects can use the Data View Builder tool to create XQuery queries graphically (without needing to code queries in XML), as well as create ad hoc XQuery queries by hand. Client applications can use the Liquid Data Query API or generated Liquid Data Web services to invoke stored XQuery queries programmatically.

About XQuery

XQuery is a standard query language, published by the W3C (World Wide Web Consortium), that uses XML (Extensible Markup Language) notation to define query requests and handle query results. XQuery is designed to be an efficient language in which queries are concise and easily understood. XQuery is flexible enough to query a broad spectrum of data sources, including relational databases, XML documents, Web services, packaged applications, and legacy systems.

Applications of XQuery include filtering a document to produce a table of contents, providing joins across multiple data sources, grouping and aggregates, and queries based on sequential relationships in documents. Joins, in particular, represent a powerful and likely principal use of XQuery in the enterprise. The XQuery language is derived from various sources, including SQL. It even provides a For-Let-Where-Return (FLWR - pronounced "flower") expression. Developers familiar with SQL will find XQuery very easy to learn.

XQuery Links

For more information about XQuery, see the following topics on the W3C's Web site:

- XQuery 1.0: An XML Query Language at the following URL:

http://www.w3.org/TR/xquery/

- XML Query Use Cases at the following URL:

http://www.w3.org/TR/xmlquery-use-cases

- XML Path Language (XPath) 2.0 at the following URL:

http://www.w3.org/TR/xpath20/

- XQuery 1.0 and XPath 2.0 Data Model at the following URL:

http://www.w3.org/TR/query-datamodel/

- XQuery 1.0 and XPath 2.0 Functions and Operators at the following URL:

http://www.w3.org/TR/xquery-operators/

XQuery Example

This section shows an example of XQuery code and sample query results from the Avitek sample. For more information about the Avitek sample, see Running the Samples.

Sample XQuery Query

The following code example shows the use of XQuery coding in a sample Order query.

Listing 3-1 XQuery for the Order Query from the Avitek Sample

>     {--	Generated by Data View Builder 	--}

>     <CustomerOrderReport>

>     {

>           for $PB-WL.CUSTOMER_1 in document("PB-WL")/db/CUSTOMER

>           where ($PB-WL.CUSTOMER_1/CUSTOMER_ID  eq  "CUSTOMER_1")

>           return

>           <customerOrder>

>                 <CUSTOMER>

>                       <FIRST_NAME>{ xf:data($PB-WL.CUSTOMER_1/FIRST_NAME) }</FIRST_NAME>

>                       <LAST_NAME>{ xf:data($PB-WL.CUSTOMER_1/LAST_NAME) }</LAST_NAME>

>                       <CUSTOMER_ID>{ xf:data($PB-WL.CUSTOMER_1/CUSTOMER_ID) }</CUSTOMER_ID>

>                       <STATE>{ xf:data($PB-WL.CUSTOMER_1/STATE) }</STATE>

>                       <EMAIL_ADDRESS>{ xf:data($PB-WL.CUSTOMER_1/EMAIL_ADDRESS) }</EMAIL_ADDRESS>

>                       <TELEPHONE_NUMBER>{ xf:data($PB-WL.CUSTOMER_1/TELEPHONE_NUMBER) }</TELEPHONE_NUMBER>

>                 </CUSTOMER>

>                 <wireless_orders>

>                 {

>                       for $PB-WL.CUSTOMER_ORDER_2 in document("PB-WL")/db/CUSTOMER_ORDER

>                       where ($PB-WL.CUSTOMER_1/CUSTOMER_ID  eq  {--! ppright !--} $PB-WL.CUSTOMER_ORDER_2/CUSTOMER_ID)

>                       return

>                       <CUSTOMER_ORDER>

>                             <ORDER_DATE>{ xf:data($PB-WL.CUSTOMER_ORDER_2/ORDER_DATE) }</ORDER_DATE>

>                             <ORDER_ID>{ xf:data($PB-WL.CUSTOMER_ORDER_2/ORDER_ID) }</ORDER_ID>

>                             <CUSTOMER_ID>{ xf:data($PB-WL.CUSTOMER_ORDER_2/CUSTOMER_ID) }</CUSTOMER_ID>

>                             <SHIP_METHOD>{ xf:data($PB-WL.CUSTOMER_ORDER_2/SHIP_METHOD) }</SHIP_METHOD>

>                             <TOTAL_ORDER_AMOUNT>{ xf:data($PB-WL.CUSTOMER_ORDER_2/TOTAL_ORDER_AMOUNT) }</TOTAL_ORDER_AMOUNT>

>                       </CUSTOMER_ORDER>

>                 }

>                 </wireless_orders>

>                 <broadband_orders>

>                 {

>                       for $XM-BB-CO.CUSTOMER_ORDER_3 in document("XM-BB-CO")/db/CUSTOMER_ORDER

>                       where ($PB-WL.CUSTOMER_1/CUSTOMER_ID  eq  {--! ppright !--} $XM-BB-CO.CUSTOMER_ORDER_3/CUSTOMER_ID)

>                       return

>                       <CUSTOMER_ORDER>

>                             <ORDER_DATE>{ xf:data($XM-BB-CO.CUSTOMER_ORDER_3/ORDER_DATE) }</ORDER_DATE>

>                             <ORDER_ID>{ xf:data($XM-BB-CO.CUSTOMER_ORDER_3/ORDER_ID) }</ORDER_ID>

>                             <CUSTOMER_ID>{ xf:data($XM-BB-CO.CUSTOMER_ORDER_3/CUSTOMER_ID) }</CUSTOMER_ID>

>                             <SHIP_METHOD>{ xf:data($XM-BB-CO.CUSTOMER_ORDER_3/SHIP_METHOD) }</SHIP_METHOD>

>                             <TOTAL_ORDER_AMOUNT>{ xf:data($XM-BB-CO.CUSTOMER_ORDER_3/TOTAL_ORDER_AMOUNT) }</TOTAL_ORDER_AMOUNT>

>                       </CUSTOMER_ORDER>

>                 }

>                 </broadband_orders>

>           </customerOrder>

>     }

>     </CustomerOrderReport>

Sample Query Results

The following listing shows the results returned in XML format from the sample Order query.

Listing 3-2 Results for the Order Query from the Avitek Sample

>     <CustomerOrderReport><customerOrder><CUSTOMER><FIRST_NAME>JOHN_1</FIRST_NAME><LAST_NAME>KAY_1</LAST_NAME><CUSTOMER_ID>CUSTOMER_1</CUSTOMER_ID><STATE>TX</STATE><EMAIL_ADDRESS>abc@abc.com</EMAIL_ADDRESS><TELEPHONE_NUMBER>4081231234</TELEPHONE_NUMBER></CUSTOMER><wireless_orders><CUSTOMER_ORDER><ORDER_DATE>2002-03-06-08:00</ORDER_DATE><ORDER_ID>ORDER_ID_1_0</ORDER_ID><CUSTOMER_ID>CUSTOMER_1</CUSTOMER_ID><SHIP_METHOD>AIR</SHIP_METHOD><TOTAL_ORDER_AMOUNT>1000</TOTAL_ORDER_AMOUNT></CUSTOMER_ORDER><CUSTOMER_ORDER><ORDER_DATE>2002-03-06-08:00</ORDER_DATE><ORDER_ID>ORDER_ID_1_1</ORDER_ID><CUSTOMER_ID>CUSTOMER_1</CUSTOMER_ID><SHIP_METHOD>AIR</SHIP_METHOD><TOTAL_ORDER_AMOUNT>2000</TOTAL_ORDER_AMOUNT></CUSTOMER_ORDER></wireless_orders><broadband_orders><CUSTOMER_ORDER><ORDER_DATE>2002-04-09</ORDER_DATE><ORDER_ID>ORDER_ID_1_0</ORDER_ID><CUSTOMER_ID>CUSTOMER_1</CUSTOMER_ID><SHIP_METHOD>AIR</SHIP_METHOD><TOTAL_ORDER_AMOUNT>1000.00</TOTAL_ORDER_AMOUNT></CUSTOMER_ORDER><CUSTOMER_ORDER><ORDER_DATE>2002-04-09</ORDER_DATE><ORDER_ID>ORDER_ID_1_1</ORDER_ID><CUSTOMER_ID>CUSTOMER_1</CUSTOMER_ID><SHIP_METHOD>AIR</SHIP_METHOD><TOTAL_ORDER_AMOUNT>1500.00</TOTAL_ORDER_AMOUNT></CUSTOMER_ORDER></broadband_orders></customerOrder></CustomerOrderReport>

Definitions of Key Terms

This topic introduces the following key Liquid Data concepts:

- Data Sources

- Queries, Results, and Schemas

- Data Views

- Caching

- Scoping and Query Hints

- Custom Functions

For a description of Liquid Data components, see Architecture Components.

Data Sources

In Liquid Data, a data source is a source of information that can be queried. Liquid Data supports querying the following types of data sources:

- Relational databases (RDBMSs) via JDBC

- XML files

- Web services

- Application views, which are business-level interfaces the data in packaged application such as Siebel, PeopleSoft, or SAP. Application views are used in conjunction with the Application Integration component of WebLogic Integration.

- data views, which are the dynamic results of queries stored along with the queries that produce them

You use the WebLogic Administration Console to configure access to data sources. For more information, see the following topics in the Liquid Data Administration Guide:

- Configuring Access to Relational Databases

- Configuring Access to XML Files

- Configuring Access to Web Services

- Configuring Access to Application Views

- Configuring Access to Data Views

You can use the Data View Builder to design and build queries that query the data sources you have configured, or you can hand-code the XQueries. Queries are built based on source and target schemas that describe the structure of the data queried (source) and returned (target). For more information about creating queries, see Building Queries and Data Views.

Queries, Results, and Schemas

A query is a request for information based on explicit criteria. In Liquid Data, queries are created and used in compliance with the XQuery language specification. With the Data View Builder, you can create queries using drag-and-drop in source and target schemas.

Users can specify two types of queries:

- Stored queries are XQuery queries that have been saved in the Liquid Data repository.

- Ad hoc queries are queries that have not been stored in the Liquid Data repository but rather are passed to the Liquid Data server on the fly. An ad-hoc query is any hand-coded query or Data View Builder-generated query that is not a stored query.

A result is the information that a query yields. In Liquid Data, the query result is generated in XML format. The target schema is an XML schema or DTD that describes the shape (structure and legal elements) of the output data—that is, the result of a query. The Liquid Data server runs queries against source data and returns the result of a query the form in which you define for target data.

For more information about queries, results, and target schemas, see Overview and Key Concepts in Building Queries and Data Views.

Data Views

A data view represents the result of a query that provides a filtered view on the data and information being queried. As such, the data view (query result) is dynamic—it will continue to reshape itself based on any changes that occur in the data it is querying. Data views can be re-used as data sources by saving them in the Liquid Data server repository. For more information about data views, see Overview and Key Concepts and Using Data Views as Data Sources in Building Queries and Data Views.

Caching

Liquid Data caches information about commonly executed queries for subsequent, efficient retrieval, thereby enhancing overall system performance. Liquid Data supports two types of caching:

- The query plan cache is a memory-based cache that stores the query plans of commonly executed queries.

- The result set cache is a database-based cache that stores the results of commonly executed queries.

For more information, see Configuring the Query Results Cache in the Liquid Data Administration Guide.

Scoping and Query Hints

The following techniques help Liquid Data expedite the processing of queries more quickly and efficiently:

- Scoping helps clarify which part of a data view is the focal point for a particular condition in a query, affecting the placement of a "where" clause in the XQuery generation. In most cases, scope is implicit and the query generator can determine what the desired result should be, while in some cases you might need to communicate your objectives explicitly. For more information, see "Understanding Scope in Basic and Advanced Views" in Designing Queries in Building Queries and Data Views.

- For join operations, a query hint specifies which join algorithm to use when running a query on the Liquid Data server. For more information, see Optimizing Queries in Building Queries and Data Views.

Custom Functions

Custom functions are user-defined functions that performed specialized tasks. The Data View Builder provides a set of standard functions for use in creating data views and queries. In addition, users can create custom functions, which are implemented in Java code, declared in a custom functions library definition (CFLD) file (in XML format), and then configured in the Administration Console. Once configured, custom functions show up as functions available for use in the Data View Builder. For more information about custom functions, see Using Custom Functions in Invoking Liquid Data Queries Programmatically and Configuring Access to Custom Functions in the Liquid Data Administration Guide.