SQL's variable structures generation capability is a very dynamic and flexible generation that is controlled by the value of data in the data structure. This flexible variable generation is applied to the joining of structures. It allows for a finer level for joining structures based on data values in the structure.
Sample Structure Data
A /\ BC
X /\ YZ
When joining structures, views that define the structure are used by the LEFT Join operation in the same way they were used in the view definition. An Example of joining the ABCview over the XYZview is: SELECT * FROM ABCView LEFT JOIN XYZView ON C.c=X.x. It generates a new larger structure, producing:
Combined Structure Data
A /\ BC | X /\ YZ
Feature 1: Look Back Data Reference
When specifying a standard variable view, the ON clause that specifies where the two views are attached also specifies a data condition from the upper view side view as in: SELECT * FROM ABCView LEFT JOIN XYZView ON C.c=X.x AND A.a=5. This logic can be embedded in a view to make it more automatic and support different cascading variable structures going down the pathway. The tested data value can be any data value going up the active path. Node C or Node A can be tested. In fact both nodes can be tested. If there is no match, this active occurrence of the path is ended without joining the lower level structure.
There is also the option to select alternative structures as in:
SELECT * FROM ABCView LEFT JOIN XYZView ON C.c=X.x AND A.a=5 LEFT JOIN XYZView2 ON C.c=X2.x AND A.a=6 LEFT JOIN XYZView3 ON C.c=X3.x AND A.a=7 This will cause only the XYZview number 1,2 or 3 that qualifies under the specified condition to be joined to ABCView depending on the value of A.a. These can be different values in each structure. This can allow the automatics building of a very variable structure for many different uses that shares common pieces of structures.
Feature 2: Look Ahead Data Reference
The look ahead option allows the variable structure test data condition to be from anywhere in the lower level view being linked to as in: SELECT * FROM ABCView LEFT JOIN XYZView ON C.c=X.x AND Z.z=6. This is lower level structure testing is possible because lower level view structures are fully expanded at the time they are joined. If the condition is not matched, this occurrence of the path is ended without the lower view having been appended. This is a very powerful capability allowing the lower level structure to be tested without joining it first in order to test it. Alternate structures can be used here also. Nested Structure Data Controls
This variable structure generation can also be specified in the view definition so that it is automatic for the query user. This can support variable cascading variable generation using embedded views each controlling their own area of control. In addition, each path can have its own separate variable structure generation which can branch out in multiple directions.
Dynamic Output Structure Control
SQL SELECT Controls Data Output Per Query
SQL's variable SELECT clause can dynamically control and process only selected portions of the input structure which also controls the data structure. This is the only portion of the data structure that will be output. This can be controlled from query to query. The SQL SELECT clause also controls hierarchical node promotion which causes unselected nodes to be sliced out of the output also modifying the structure. This is also occurring naturally in relational processing and is known as projection. XQuery does not have this automatic dynamic structure modification control.
The interactive demo below can be activated by clicking on it. It performs live queries of dynamic structure output which includes dynamic and variable structures controlled by the user or data values in the data.