The Building Blocks: Tuples and Sets
Many of us have, by now, come across the argument
surrounding the pronunciation of the word "tuple" that rages within the OLAP
and associated arenas. Few disagree, however, as to the importance of the role
that the tuple plays in MDX syntax in general, in set construction
specifically, and in overall expression building. Axes, too, play an
important role in locating values along the dimension members they represent.
In addition, sets comprise the next level of construction, and share
importance as a significant building block within MDX.
We will take a look at these three basic elements
of multidimensional structures first, as we prepare for subsequent lessons
covering more advanced components and concepts within the MDX language. We
will perform straightforward practice exercises at appropriate junctures to
reinforce our understanding of the concepts as we introduce them.
Tuples
Discussion
A tuple is a collection of members, each of
which is selected from a different dimension. To illustrate, (Sales,
1997) conceptually represents a tuple that is composed of members that
might exist in an OLAP cube from two dimensions: measures (recall that
measures are yet another dimension from a syntactical perspective) and time.
The tuple (Non-Consumable, Sales, 1997) is composed of members of three
different dimensions: product, measures, and time. The
tuple is the basic unit for forming an axis, which we will discuss
below.
An important thing to remember when considering tuples is
that, while they can be composed of one or more members from a number of
dimensions, only one member from each dimension can exist in a given tuple. A
tuple can be composed of any and all dimensions, including, as we have already
noted, the measures dimension.
Syntax
The syntax for a tuple follows a few basic rules, the chief
of which are detailed in Table 1 below:
|
|
|
|
|
|
|
|
|
|
|
SPECIFICATION
|
|
GENERAL RULE
|
|
SYNTAX
|
|
NOTES
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Single Member / Single
Dimension
|
|
List dimension alone
|
|
[Dimension].[Member]
|
|
(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Multiple Members / Multiple
Dimensions
|
|
Surround tuple membership in
parentheses
|
|
([Dim1].[Member],
[Dim2].[Member], [Dim3].[Member])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NOTES:
|
|
|
|
|
|
|
|
|
(1) Single
members can be enclosed within parentheses, but are not required to be.
|
|
|
|
|
|
|
|
|
|
Table 1: Syntax Table: Tuples (General)
With square brackets "[ ]" serving as delimiting
characters, MDX uses tuples to identify cell "addresses." Any cell value can
be mapped using a tuple made up of one distinct member from each of a cube's
dimensions. We can project dimensions to columns, rows, pages and other axes
(see the Axes section below). An important concept to carry away
from this section is that every intersection of multiple tuples results in yet
another tuple. The ultimate outcome off combining all the tuples in a query
is, after all, a cell with a value that is defined by the coordinates provided
within the "grand tuple." In usage, a tuple refers to either a combination of
members (the "grand tuple") -- and the cell that the combination defines (an
"address", as it were) -- or to the value or values in the cell or cells that
is specified by the tuple.
We will revisit this concept many times over the series, so
as to examine it and understand it from multiple perspectives. Seeing concepts
in action is often the best way to learn, and there will be ample opportunity
to do so as we progress.
Page 3: Axes