Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between tuple and set in mdx

Tags:

sql

ssas

mdx

What is the difference between tuple and set in MDX. How we can distinguish both and when we are using them.

like image 372
Searcher Avatar asked Mar 01 '12 14:03

Searcher


People also ask

What are tuples in MDX?

A tuple uniquely identifies a slice of data from a cube. The tuple is formed by a combination of dimension members, as long as there are no two or more members that belong to the same hierarchy.

What is an MDX member?

An MDX calculated member is defined by creating and building an MDX expression. Procedure. To create an MDX calculated member: In the Data Project Explorer, expand the cube model that contains the dimension object for which you want to create an MDX calculated member under its hierarchies.

Is MDX similar to SQL?

MDX is a query language designed for OLAP databases, as SQL is a query language for relational databases. MDX is essentially an extension to SQL used for queries and script access to multidimensional data. MDX queries access data stored in a SQL Server Analysis Server cube by bringing back facts related to dimensions.

What are MDX queries?

Multidimensional Expressions (MDX) is a query language for online analytical processing (OLAP) using a database management system. Much like SQL, it is a query language for OLAP cubes. It is also a calculation language, with syntax similar to spreadsheet formulas.


2 Answers

Having come to MDX from a more maths perspective this is my take on the question:

Imagine you have 3d Cube with dimensions X, Y and Z. The number of cells in the cube is number of members in X multiplied by the number of members of Y multiplied by the number of members of Z.

Each cell with have a coordinate in the cube based on a value from X, Y and Z. That coordinate is a Tuple.

So lets say :

  • X is Measures,
  • Y is Years,
  • Z is Products,

Then a single cell could be the laptop sales for 1999. The cell coordinate will be: logically (X, Y, Z) and physically this is a tuple such as

(Measures.Sales, Years.[1999], Products.[Laptop])  

Now lets say we want multiple cells, then we need multiple tuples, right? Yes, a Set is basically multiple tuples. Actually by multiple I include 0 and 1. So extending our example, we could have laptops from 1999 and desktops from 2001:

{ 
    (Measures.Sales, Years.[1999], Products.[Laptop]) ,
    (Measures.Sales, Years.[2001], Products.[Desktop]) 
}

So you can see that you end up with multiple items with a set, and a single item with a tuple......

like image 139
Preet Sangha Avatar answered Sep 22 '22 23:09

Preet Sangha


A tuple is a single hierarchy member taken from all the dimensions. Suppose Time.[2nd half] is a tuple of time dimension. At the same way we can have multiple tuples and we represent them in '(',')' brackets. Eg:

(Time.[2nd half], Color.Dark.Red).

This is nothing but the mathematical intersection of nodes. we can represent the nodes in maths as (2,1) in the same way above expression will work.

Now coming to sets it is nothing but the composition of tuples. set contains one or more tuples it may zero also. we represent them in { , } braces. Eg:

{ (Time.[1st half], Color.Dark.Red), (Time.[2nd half], Color.Dark.Blue) }
like image 23
Mihir Avatar answered Sep 22 '22 23:09

Mihir