Hierarchical Structure Mashups
Previously, joined data structures linked only to the root of the lower-level structure, to keep the modeled structure valid hierarchically (as in Figure 3
). Linking to nodes below the root of the lower-level structure has been problematic, because it's difficult to determine the new derived structure and its semantics. For example, the query in Figure 6
joins the relational structure (RDB) to the lower XML structure by linking below its root to the L
node based on the ON clause relationship. This is possible because the lower level structure has already been fully materialized when joining views. On its own, this creates an invalid hierarchical structure, because the L
node is accessible from multiple paths (X
). In other words, the semantics of the structure in Figure 7
are ambiguous as shown.
|Figure 6. Structure Mashup and Relationships: Joining node R to node L (below the root of the structure X-M-L) seemingly creates an ambiguous structure, because L can be reached via two paths.||
|Figure 7. Correct Data Modeling: This mashup query illustrates linking below the root.||
However, by matching the results to the semantics of the result something very interesting and quite intuitive happens. The semantics of the resulting new structure always behaves as if the lower level structure's root were linked to as shown in Figure 7
. Because this is already standard processing, it requires no special changes in the hierarchical processing other than recognizing this new situation in the data modeling process and adjusting for it as indicated. This new hierarchical data modeling finding means that hierarchical structures can be combined based on relationships anywhere in the data to mashup the data structures using ANSI SQL.
This new hierarchical data modeling finding is semantically accurate. In Figure 7, the lower structure is already a valid hierarchical structure, based on its root (X), which does not change when it's combined with another structure. This enables the upper level structure can be related to the lower structure by matching values anywhere in the lower structure.
The breakthrough with this hierarchical data modeling finding is that it always uses the root of the lower level as its link point for determining the combined structure. This keeps the lower level structure's semantics stable. The lower level structure has been filtered to represent only the values that reflect the linking requirements in the associated ON clause, (R.r=L.l in Figure 7).
In Figure 7 the XML structure has been filtered based on a value in its lower level L node, but the connection point to the upper level is at its root node X and not its L node. This makes sense because node L is below node X; you have to access node X to locate the correct L node. So the new structure preserves correct semantics. This also means that you can reference and filter multiple lower level nodes correctly using an ON clause specifying R.r=L.l AND R.r=M.m. In that case the resulting structure would be the same, but with more complex automatic data filtering of the lower level. You can see this is extremely powerful, and it can be performed interactively.
To sum up, mashing up structures should not change their basic structure. Changes to the basic data structure should be done by transformation operations. The new data modeling semantics of linking below the root for data mashups also helps supports advanced new transformation capabilities, which I'll discuss in a future article. For additional information on this new level of SQL/XML hierarchical integration discussed in this article and to test it online yourself, try this demo.