As this web site shows, our ANSI SQL native XML integration technology supports full and seamless hierarchical processing. This includes direct and seamless SQL access and hierarchical processing of native XML data values and the flexible and powerful hierarchical joining of hierarchical data structures. What is even more amazing about this breakthrough ANSI standard SQL technology is that it also naturally handles XML’s more advanced capabilities such as node promotion, fragment support, structure transformation, and variable structures as the examples below demonstrate. All of these hierarchical operations are also performed at a very high hierarchical structure conceptual level. This shows that SQL qualifies as an excellent non procedural and standard hierarchical query language for processing and integrating relational and hierarchical (legacy and XML) data. These examples also demonstrate SQL’s natural joining of hierarchical structures.
Flexible Fragment Processing
As shown below, the standard SQL defined fragment support operates on multi-leg structures and non procedurally joins the identified encircled fragment portion hierarchically to the upper structure using a simple ANSI SQL query. The specification of this operation is very intuitive, the fragment is defined by which nodes have data selected for output by the SELECT clause as can be seen below. The joining of this hierarchical fragment is performed by linking to its new root which is below the original root. This is possible because the lower view is materialized before it is linked in (when nested views expand they push the outer level ON clause to the right causing the outer level join to be delayed until the inner level joins are fully materialized). The resulting structure derived is as desired and expected, and follows ANSI SQL syntax and semantics.
This advanced XML processing is handled automatically, naturally and seamlessly in standard non procedural ANSI SQL as shown in the ANSI SQL query above. View1 and View2 are ANSI SQL outer join views that define hierarchical data structures using standard left outer joins which are represented by their identified structure diagrams. The standard SQL query Selects the data that is desired for output, naturally identifying the structure fragment in the encircled portion of the lower structure. This fragment is linked to the upper level structure as specified by the ON clause to produce the result structure shown. This is a very sophisticated yet intuitive operation performed easily, and one that fully follows ANSI SQL syntax and semantics. The final result is materialized when only the requested data is moved from working (processing) storage to the final result.
Node Promotion and Collection with Fragments
The example below also demonstrates node promotion and node collection operating in harmony with fragment creation and processing. The fragment from the example above has been expanded as shown in the encircled area below. In this example some of the nodes within thefragment’s encircled area have not been Selected for output and are not moved to the output result. This automatically caused the lower level nodes to be promoted up the path to the next node Selected for output. This can also cause nodes from different paths to be collected under a common node as shown with nodes “Y” and “J” under “F”. Nodes that are defined in the structure with the FROM clause, but are not Selected for output, can still be referenced in the query such as node “P”. All of these operations also follow ANSI SQL syntax and semantics and are performed by the Cartesian product model of relational databases. The node promotion and node collection is performed automatically when only the requested data is moved from working (processing) storage to the final result which slices out the remaining unselected data. This slicing out action preserves the basic structure of the SQL data modeled structure processed as demonstrated below.
By combining fragment processing and the Alias feature used in duplicate element processing, it is possible to easily perform powerful structure transformations. This operates by specifying different fragments from the same structure by using the Alias capability to logically create multiple copies of the same structure so that different fragments can be isolated and then independently manipulated. The Alias feature can be used to rename views which enables duplicate input structures to be logically defined so that references to them can be made unambiguously (useful for namespaces). The example below demonstrates this by creating two separate and independent fragments from the StoreView view and structure which are encircled. These fragments are then recombined into a different structure by re-joining them. This isa simple example of structure transformation, multiple structures can each have multiple fragments extracted which can all be combined in any order. The fragments can be joined as they are needed. Structural transformations can also be put into an SQL view for easy reuse and use in larger structures.
XML can define variable structures which allow for considerable variability of structure formats for a single definition of the structure. This means that from structure occurrence to occurrence or even within a single structure occurrence of a record or document, the structure format can vary. Usually with a varying structure, some piece of information from a higher level in the structure can indicate how a variable sub structure is to form. With this information, SQL data modeling (Left Joins) which controls the building of each structure occurrence can define the appropriate sub structures dynamically. An example is shown below.
This is a simple example where the generation of the data structure can vary depending on the value of the field StoreType in the Store node. In this case, only one sub structure was affected, but there is no limit to the number of variations which can be controlled by the ON clauses testing for any number of structure indicator values to control whether they are generated depending on the current data values. (Unlike WHERE clauses, ON clauses control joining at the point in the syntax they are specified.) These ON Clause tests can be coded to duplicate the rules specified in XML DTD and Schemas for variable element generation which can become quite complex. The variable structure SQL above defines how the structured record is constructed in memory and can be used to control navigation of the variable record for retrieval and its output format.
Mapping Network Structures to Hierarchical Structures
Network structures unlike hierarchical structures allow a node to be accessed from more than one path. This is demonstrated below in the IDREF structure. This makes them ambiguous for non procedural, navigationless languages like SQL because each path has its own semantics. But XML is hierarchical, why are we concerned with network structures? Because there are a couple of capabilities in XML that allow it to model a logical network structure.
Duplicate named XML elements and IDREF XML constructs both cause a network type structure to be defined as shown below. In both examples, the Addr node(s) have two separate pathsand two separate semantics in each example. Interestingly, even though the physical storage is different between these two structures, they are semantically the same for input. This can be handled in ANSI SQL by modeling these structures as their equivalent hierarchical structures producing a hierarchical structure that maps both hierarchical type structures to an unambiguous hierarchical structure.
When the SQL data being accessed is defined hierarchically by outer joins, it causes SQL's processing to be performed at a full hierarchical level. Hierarchical processing is not unique to SQL, its principles of operation are independent of its processing methods and of the storage methods of the hierarchical data. This enables the seamless processing of heterogeneous data structures and means that the basic results shown above are inherent to hierarchical processing regardless of how processed or implemented.