SQL mdx中元组和集合的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9517520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between tuple and set in mdx
提问by Searcher
What is the difference between tuple
and set
in MDX. How we can distinguish both and when we are using them.
MDXtuple
和set
MDX之间有什么区别。我们如何区分两者以及何时使用它们。
回答by Preet Sangha
Having come to MDX from a more maths perspective this is my take on the question:
从更数学的角度来到 MDX,这是我对这个问题的看法:
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.
假设您有一个尺寸为 X、Y 和 Z的3d 立方体。立方体中的单元格数是 X 中的成员数乘以 Y 的成员数乘以 Z 的成员数。
Each cell with have a coordinate in the cube based on a value from X, Y and Z. That coordinate is a Tuple.
每个单元格在立方体中都有一个基于 X、Y 和 Z 值的坐标。该坐标是一个 Tuple。
So lets say :
所以让我们说:
- X is Measures,
- Y is Years,
- Z is Products,
- X 是度量,
- Y 是年,
- Z 是产品,
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
那么单个单元格可以是 1999 年的笔记本电脑销售量。单元格坐标将是:逻辑上(X, Y, Z)
和物理上这是一个元组,例如
(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:
现在假设我们想要多个 cell,那么我们需要多个元组,对吗?是的,一个 Set 基本上是多个元组。实际上通过多个我包括 0 和 1。所以扩展我们的例子,我们可以有 1999 年的笔记本电脑和 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......
所以你可以看到你最终得到了一个集合的多个项目,以及一个带有元组的单个项目......
回答by Mihir
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]
是一个时间维度的元组。同样,我们可以有多个元组,并将它们表示在 '(',')' 括号中。例如:
(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.
这只不过是节点的数学交集。我们可以用与上面表达式相同的方式将数学中的节点表示为 (2,1)。
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:
现在来设置它只不过是元组的组合。set 包含一个或多个元组,它也可以归零。我们用 { , } 大括号表示它们。例如:
{ (Time.[1st half], Color.Dark.Red), (Time.[2nd half], Color.Dark.Blue) }
回答by Yuriy Guts
This articledescribes the terms Member, Tupleand Setin details.
本文详细描述了术语Member、Tuple和Set。
I'll try to explain it in an easy way.
我将尝试以简单的方式解释它。
Simply put, a tupleis an atomic slice of data in a dimension and a setis a collection of tuples. For example, you can have a Books
dimension with tuples Sherlock Holmes
, Tom Sawyer
, CLR via C#
, Code Complete
and Quantum Physics for Dummies
.
After that, you can organize these tuples into named sets, like Programming
, Fiction
and Natural Sciences
.
简单地说,一个元组是数据的维度中的原子片和一套是元组的集合。例如,你可以有一个Books
与元组层面Sherlock Holmes
,Tom Sawyer
,CLR via C#
,Code Complete
和Quantum Physics for Dummies
。
之后,您可以将这些元组组织成命名集,如Programming
、Fiction
和Natural Sciences
。
[Books].&[Sherlock Holmes] -- Tuple
[Books].&[CLR via C#] -- Tuple
{ [Books].&[CLR via C#], [Books].&[Code Complete] } -- Set
There are certain functionsin MDX that return sets or tuples, and it's often helpful to know how to convert a tuple to a set and vice versa. For example, the Item(...)
function takes a specific tuple from a set. Enclosing multiple tuples in { , , }
will create a set with these tuples.
MDX 中有某些函数会返回集合或元组,了解如何将元组转换为集合以及反之亦然通常很有帮助。例如,该Item(...)
函数从集合中获取特定的元组。包含多个元组{ , , }
将创建一个包含这些元组的集合。
The example I described is pretty partial and doesn't cover the whole theory, but it might give you a good basic understanding of how these concepts work.
我描述的示例非常片面,并没有涵盖整个理论,但它可能会让您对这些概念的工作原理有一个很好的基本了解。
回答by Ganijon Rahimov
Here's the another good explanation from: http://www.onlineexpert.com/elearning/user/pdf/APPLICATIONDEVELOPMENT/SQL2KOLAP/Ch08.pdf.
这是另一个很好的解释:http: //www.onlineexpert.com/elearning/user/pdf/APPLICATIONDEVELOPMENT/SQL2KOLAP/Ch08.pdf。
It's similar to Preet Sangha's answer.
这类似于 Preet Sangha 的回答。