SQL Server商业智能功能–创建简单的OLAP多维数据集

介绍 (Introduction)

多维多维数据集和事务数据库是两个非常不同的事物。 从经验中,我什至是经验丰富的DBA都完全避免使用多维数据集这一主题,因为对于他们而言,多维数据集实在是一个未知领域。 通常,多维数据集工作会传递给开发人员,因为他们可以轻松使用Visual Studio。 这是非常遗憾的,因为实际上创建OLAP多维数据集并不是很困难。 可以肯定地说,大多数工作需要在传统SQL Server数据库引擎/ SSIS环境中完成,从创建数据仓库模型到保持ETL数据包的状态。 本文假设您已经有一个数据仓库,并以AdventureWorksDW2012为例。 遵循这些步骤将使您踏上基于读取优化的OLAP多维数据集的体面SQL Server商业智能解决方案。
  • *Please note: You will need SQL Server Data Tools or SQL Server Business Intelligence Developments Studio (BIDS). You can get it here.
  • *请注意:您将需要SQL Server数据工具或SQL Server商业智能开发工作室(BIDS)。 你可以在这里得到。

入门 (Getting started)

Every OLAP cube is created with an analytics solution. To create one, open SQL Server Data Tools or BIDS and create a new “Analysis Services Multidimensional and Data Mining Project”

每个OLAP多维数据集都是使用分析解决方案创建的。 要创建一个,请打开SQL Server数据工具或BIDS并创建一个新的“ Analysis Services多维和数据挖掘项目”

Creating a new project using SQL Server Data Tools or BIDS

This will open a blank solution and will create the basic folders needed in the solution explorer. Something that is quite handy to know about SQL Server Analysis projects is that the order of creation or the workflow follows the order of the folders in the Solution Explorer.

这将打开一个空白解决方案,并将创建解决方案资源管理器中所需的基本文件夹。 关于SQL Server Analysis项目,很容易知道的一点是,创建或工作流的顺序遵循解决方案资源管理器中文件夹的顺序。

So the order of creation has to be:

因此创建顺序必须为:

  1. Data Source

    数据源
  2. Data Source View

    数据源视图
  3. OLAP Cube

    OLAP多维数据集
  4. Dimensions

    外型尺寸

The order of the folders in the Solution Explorer

So let’s start by creating a new data source. To do this, right click on Data Sources and click “New Data Source”. This will open a wizard that will allow you to make a normal database connection to your data warehouse:

因此,让我们开始创建一个新的数据源。 为此,请右键单击“数据源”,然后单击“新数据源”。 这将打开一个向导,该向导将允许您与数据仓库建立正常的数据库连接:

Data source creation - Creating a database connection

In the next step you will be asked to specify the type of connection. It is important here to think of the type of security you will need for your OLAP cube. I recommend creating service account on your Active Directory and using the “Use a specific Windows user name and password” option to set this user. You can find more information about this here.

在下一步中,将要求您指定连接类型。 在这里重要的是要考虑OLAP多维数据集所需的安全性类型。 建议您在Active Directory上创建服务帐户,并使用“使用特定的Windows用户名和密码”选项来设置该用户。 您可以在此处找到有关此信息的更多信息。

Data Source Wizard - specifying the type of the connection

Having completed this step you now have a source of data for your OLAP cube. Next you have to create a data source view and specify which data you want to use for your cube. This is done by right clicking on the Data Source Views folder and adding a new one. The wizard will ask you which connection you would like to use and which fact / dimension tables you want to base your cube on. Generally you will want to select all dimension and fact tables and deal with the partitioning later in the cube, so you can go ahead and do this. You also have the option of choosing only parts of your data warehouse. For simplicity I have done this and only chosen the Internet Sales sections of the AdventureWorksDW2012 database.

完成此步骤后,您现在有了OLAP多维数据集的数据源。 接下来,您必须创建一个数据源视图,并指定要用于多维数据集的数据。 可以通过右键单击“数据源视图”文件夹并添加一个新文件夹来完成。 向导将询问您要使用哪个连接,以及要作为多维数据集基础的事实/维度表。 通常,您将需要选择所有维度表和事实表,并稍后在多维数据集中处理分区,因此可以继续进行操作。 您还可以选择仅选择数据仓库的一部分。 为简单起见,我这样做了,仅选择了AdventureWorksDW2012数据库的“ Internet销售”部分。

Creating a data source view - specifying which data you want to use for your cube

It is important to have correct foreign key relations in your data warehouse beforehand because SQL Server Data Tools is able to create a decent view diagram using existing relations in the DW. If you have not done this you will have to explicitly specify the relations between your fact and dimension tables. If all goes well you will have a view similar to this:

事先在数据仓库中具有正确的外键关系很重要,因为SQL Server数据工具能够使用DW中的现有关系创建体面的视图。 如果尚未执行此操作,则必须明确指定事实表和维表之间的关系。 如果一切顺利,您将具有类似于以下的视图:

SQL Server Data Tools - View diagram

Now comes the fun part: creating the cube structure. Once you have a data source view set up you can create a cube. Right click on “Cubes” and create a “New Cube”. In this wizard you should choose to “Use existing tables”. You will then be prompted to select your “Measure Group Tables”. These are your fact tables. Select them and click next. The wizard will then automatically detect fields that can be used as measures. Click next again. Assuming your foreign keys were correct in the DW or you did the explicit relations correctly in the data source view, the wizard will now automatically select the necessary dimensions. In order to explicitly declare the relations between tables the easiest way is to drag and drop the joins between the table key / foreign key in the interface / data source view model. Once this is done, click next once again. Give your cube a name and click “Finish”.

现在来了有趣的部分:创建多维数据集结构。 一旦设置了数据源视图,就可以创建多维数据集。 右键单击“多维数据集”,然后创建“新多维数据集”。 在此向导中,您应该选择“使用现有表”。 然后将提示您选择“度量值组表”。 这些是您的事实表。 选择它们,然后单击下一步。 然后,向导将自动检测可用作度量的字段。 再次单击下一步。 假设您的外键在DW中是正确的,或者您在数据源视图中正确地执行了显式关系,该向导现在将自动选择必要的尺寸。 为了明确声明表之间的关系,最简单的方法是在接口/数据源视图模型中拖放表键/外键之间的联接。 完成后,再次单击下一步。 给您的多维数据集命名,然后单击“完成”。

Cube Wizard - setting the cube name, reviewing its structure

Voila! You now have your very first cube structure. It should look something like this:

瞧! 现在,您有了第一个多维数据集结构。 它看起来应该像这样:

Cube structure preview

You are nearly done. The basic configuration is complete but your cube only exists as a blueprint at this stage. In order to create it on your Analysis Services server you first need to tell Data Tools where your server is located. This is done by clicking on Project > [YourProjectName] Properties and then going to the deployment tab. Here you can specify the location of your Analysis Services server and the name of your database (if it does not exist it will be created):

您快完成了。 基本配置已完成,但是您的多维数据集在此阶段仅作为蓝图存在。 为了在Analysis Services服务器上创建它,您首先需要告诉Data Tools服务器所在的位置。 单击“项目”>“ [YourProjectName]属性”,然后转到“部署”选项卡,即可完成此操作。 在这里,您可以指定Analysis Services服务器的位置和数据库的名称(如果不存在,则将创建数据库):

Cube property page - deployment tab

To create the cube and process the data from the data warehouse to the new cube you need to click Build > Process… in the superior Visual Studio toolbar or by right clicking on your cube file within the solution.This will bring up a screen saying your database is out of date (which is normal as it does not exist yet), agree to build and deploy your project and Data Tools will create the database. Next a “Process Cube” screen will appear:

要创建多维数据集并处理从数据仓库到新多维数据集的数据,您需要单击高级Visual Studio工具栏中的Build> Process…,或在解决方案中右键单击您的多维数据集文件。这将弹出一个屏幕,提示您数据库已过时(这是正常的,因为尚不存在),请同意构建和部署您的项目,然后数据工具将创建数据库。 接下来将出现“ Process Cube”屏幕:

Process Cube dialog

At this screen you can leave everything as default and click “Run…” and if you have no configuration errors your cube will process:

在此屏幕上,您可以将所有内容保留为默认值,然后单击“运行...”,如果没有配置错误,则多维数据集将处理:

Process progress dialog - process succeeded

Once you have processed the cube for the first time you can explore the data through the solution by opening the cube and clicking on the “Browser” tab. You can also bring up the same screen by opening SQL Server Management Studio and connecting to your Analysis Server (careful not to connect to the usual database engine) and right clicking on the cube. There you can choose “Explore”.

首次处理多维数据集后,您可以通过打开多维数据集并单击“浏览器”选项卡来浏览解决方案中的数据。 您还可以通过打开SQL Server Management Studio并连接到Analysis Server(请注意不要连接到常用的数据库引擎)并右键单击多维数据集来调出相同的屏幕。 在这里,您可以选择“浏览”。

Exploring the created cube

On this screen you can verify the data in the cube and also generate basic queries to use in your reports. The reports also have this query designer window if you choose an analysis source instead of a normal SQL Server database source. The queries created are in MDX format which is a whole other language. You can get a feel for it on the MSDN website. However, the subject of creating SSRS reports based on MDX queries will be covered in a later article.

在此屏幕上,您可以验证多维数据集中的数据,还可以生成要在报表中使用的基本查询。 如果您选择分析源而不是普通SQL Server数据库源,则报表也具有此查询设计器窗口。 创建的查询采用MDX格式,这是另一种语言。 您可以在MSDN网站上找到它。 但是,在以后的文章中将介绍基于MDX查询创建SSRS报告的主题。

从这里到哪里? (Where to from here?)

Once you have a basic cube up and running there are many things you may want to do to enhance the user experience. Some examples of advanced features are calculated measures (to create year to date sums or current month sums that are pre-calculated), hierarchical dimensions which can be used to order dimensions and allow for a more meaningful drill down to the data a user may need. These types of things can be added to the cube by using the selection of tabs in the Cube screen in Data Tools:

一旦建立了基本的多维数据集并开始运行,您可能需要做很多事情来增强用户体验。 高级功能的一些示例包括:计算量度(用于创建预先计算的年初至今的总和或当月总和),可用于订购维度的分层维度,并允许更有意义地向下钻取用户可能需要的数据。 通过使用“数据工具”中“多维数据集”屏幕中的选项卡选择,可以将这些类型的事物添加到多维数据集中:

Cube screen in SQL Server Data Tools

Once the changes have been made to your cube solution you can apply them to the cube by reprocessing from the analytics solution as you did above.

对多维数据集解决方案进行更改后,您可以像上面一样通过从分析解决方案重新处理将它们应用于多维数据集。

In conclusion, you may want to think of the following things:

总之,您可能需要考虑以下几点:

  • Add a cube processing step to your ETL package that is used to update the data warehouse.

    将多维数据集处理步骤添加到用于更新数据仓库的ETL包中。
  • Set up your report server and start creating reports

    设置您的报告服务器并开始创建报告
  • Add advanced calculated measures, hierarchical dimensions and cube perspectives

    添加高级计算量度,层次结构维度和多维数据集透视图
  • Investigate the utility of SharePoint and self-service reports

    调查SharePoint和自助服务报告的实用程序

参考资料 ( References)

The Basic MDX Query
SSAS Impersonation Smackdown – Specific Windows Acct vs Service Acct How to Create an Analysis Services Cube

基本MDX查询
SSAS模拟模仿-特定的Windows Acct与Service Acct 如何创建Analysis Services多维数据集

翻译自: https://www.sqlshack.com/sql-server-business-intelligence-features-olap-cube-creating/

  • 0
    点赞
  • 0
    评论
  • 6
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
©️2021 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值