1. Trang chủ
  2. » Công Nghệ Thông Tin

Microsoft SQL Server 2008 R2 Unleashed- P212 doc

10 92 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Table of Contents

  • Introduction

  • Part I: Welcome to Microsoft SQL Server

    • 1 SQL Server 2008 Overview

      • SQL Server Components and Features

      • SQL Server 2008 R2 Editions

      • SQL Server Licensing Models

      • Summary

    • 2 What’s New in SQL Server 2008

      • New SQL Server 2008 Features

      • SQL Server 2008 Enhancements

      • Summary

    • 3 Examples of SQL Server Implementations

      • Application Terms

      • OLTP Application Examples

      • DSS Application Examples

      • Summary

  • Part II: SQL Server Tools and Utilities

    • 4 SQL Server Management Studio

      • What’s New in SSMS

      • The Integrated Environment

      • Administration Tools

      • Development Tools

      • Summary

    • 5 SQL Server Command-Line Utilities

      • What’s New in SQL Server Command-Line Utilities

      • The sqlcmd Command-Line Utility

      • The dta Command-Line Utility

      • The tablediff Command-Line Utility

      • The bcp Command-Line Utility

      • The sqldiag Command-Line Utility

      • The sqlservr Command-Line Utility

      • Summary

    • 6 SQL Server Profiler

      • What’s New with SQL Server Profiler

      • SQL Server Profiler Architecture

      • Creating Traces

      • Executing Traces and Working with Trace Output

      • Saving and Exporting Traces

      • Replaying Trace Data

      • Defining Server-Side Traces

      • Profiler Usage Scenarios

      • Summary

  • Part III: SQL Server Administration

    • 7 SQL Server System and Database Administration

      • What’s New in SQL Server System and Database Administration

      • System Administrator Responsibilities

      • System Databases

      • System Tables

      • System Views

      • System Stored Procedures

      • Summary

    • 8 Installing SQL Server 2008

      • What’s New in Installing SQL Server 2008

      • Installation Requirements

      • Installation Walkthrough

      • Installing SQL Server Using a Configuration File

      • Installing Service Packs and Cumulative Updates

      • Slipstream Installations

      • Summary

    • 9 Upgrading to SQL Server 2008

      • What’s New in Upgrading SQL Server

      • Using the SQL Server Upgrade Advisor (UA)

      • Destination: SQL Server 2008 or SQL Server 2008 R2

      • Upgrading Using a Configuration File

      • Slipstreaming Upgrades

      • Upgrading Other SQL Server Components

      • Summary

    • 10 Client Installation and Configuration

      • What’s New in Client Installation and Configuration

      • Client/Server Networking Considerations

      • Client Installation

      • Client Configuration

      • Client Data Access Technologies

      • Summary

    • 11 Security and User Administration

      • What’s New in Security and User Administration

      • An Overview of SQL Server Security

      • Authentication Methods

      • Managing Principals

      • Managing Securables

      • Managing Permissions

      • Managing SQL Server Logins

      • Managing SQL Server Users

      • Managing Database Roles

      • Managing SQL Server Permissions

      • The Execution Context

      • Summary

    • 12 Data Encryption

      • What’s New in Data Encryption

      • An Overview of Data Security

      • An Overview of Data Encryption

      • SQL Server Key Management

      • Column-Level Encryption

      • Transparent Data Encryption

      • Column-Level Encryption Versus Transparent Data Encryption

      • Summary

    • 13 Security and Compliance

      • Exposure and Risk

      • Across the Life Cycle

      • The Security Big Picture

      • Identity Access Management Components

      • Compliance and SQL Server

      • SQL Server Auditing

      • Setting Up Auditing via T-SQL

      • SQL Injection Is Easy to Do

      • Summary

    • 14 Database Backup and Restore

      • What’s New in Database Backup and Restore

      • Developing a Backup and Restore Plan

      • Types of Backups

      • Recovery Models

      • Backup Devices

      • Backing Up a Database

      • Backing Up the Transaction Log

      • Backup Scenarios

      • Restoring Databases and Transaction Logs

      • Restore Scenarios

      • Additional Backup Considerations

      • Summary

    • 15 Database Mail

      • What’s New in Database Mail

      • Setting Up Database Mail

      • Sending and Receiving with Database Mail

      • Using SQL Server Agent Mail

      • Related Views and Procedures

      • Summary

    • 16 SQL Server Scheduling and Notification

      • What’s New in Scheduling and Notification

      • Configuring the SQL Server Agent

      • Viewing the SQL Server Agent Error Log

      • SQL Server Agent Security

      • Managing Operators

      • Managing Jobs

      • Managing Alerts

      • Scripting Jobs and Alerts

      • Multiserver Job Management

      • Event Forwarding

      • Summary

    • 17 Administering SQL Server 2008 with PowerShell

      • What’s New with PowerShell

      • Overview of PowerShell

      • PowerShell Scripting Basics

      • PowerShell in SQL Server 2008

      • Step-By-Step Examples

      • Summary

    • 18 SQL Server High Availability

      • What’s New in High Availability

      • What Is High Availability?

      • The Fundamentals of HA

      • Building Solutions with One or More HA Options

      • Other HA Techniques That Yield Great Results

      • High Availability from the Windows Server Family Side

      • Summary

    • 19 Replication

      • What’s New in Data Replication

      • What Is Replication?

      • The Publisher, Distributor, and Subscriber Magazine Metaphor

      • Replication Scenarios

      • Subscriptions

      • Replication Agents

      • Planning for SQL Server Data Replication

      • SQL Server Replication Types

      • Basing the Replication Design on User Requirements

      • Setting Up Replication

      • Scripting Replication

      • Monitoring Replication

      • Summary

    • 20 Database Mirroring

      • What’s New in Database Mirroring

      • What Is Database Mirroring?

      • Roles of the Database Mirroring Configuration

      • Setting Up and Configuring Database Mirroring

      • Testing Failover from the Principal to the Mirror

      • Client Setup and Configuration for Database Mirroring

      • Migrate to Database Mirroring 2008 as Fast as You Can

      • Using Replication and Database Mirroring Together

      • Using Database Snapshots from a Mirror for Reporting

      • Summary

    • 21 SQL Server Clustering

      • What’s New in SQL Server Clustering

      • How Microsoft SQL Server Clustering Works

      • Installing SQL Server Clustering

      • Summary

    • 22 Administering Policy-Based Management

      • Introduction to Policy-Based Management

      • Policy-Based Management Concepts

      • Implementing Policy-Based Management

      • Sample Templates and Real-World Examples

      • Policy-Based Management Best Practices

      • Summary

  • Part IV: Database Administration

    • 23 Creating and Managing Databases

      • What’s New in Creating and Managing Databases

      • Data Storage in SQL Server

      • Database Files

      • Creating Databases

      • Setting Database Options

      • Managing Databases

      • Summary

    • 24 Creating and Managing Tables

      • What’s New in SQL Server 2008

      • Creating Tables

      • Defining Columns

      • Defining Table Location

      • Defining Table Constraints

      • Modifying Tables

      • Dropping Tables

      • Using Partitioned Tables

      • Creating Temporary Tables

      • Summary

    • 25 Creating and Managing Indexes

      • What’s New in Creating and Managing Indexes

      • Types of Indexes

      • Creating Indexes

      • Managing Indexes

      • Dropping Indexes

      • Online Indexing Operations

      • Indexes on Views

      • Summary

    • 26 Implementing Data Integrity

      • What’s New in Data Integrity

      • Types of Data Integrity

      • Enforcing Data Integrity

      • Using Constraints

      • Rules

      • Defaults

      • Summary

    • 27 Creating and Managing Views in SQL Server

      • What’s New in Creating and Managing Views

      • Definition of Views

      • Using Views

      • Creating Views

      • Managing Views

      • Data Modifications and Views

      • Partitioned Views

      • Indexed Views

      • Summary

    • 28 Creating and Managing Stored Procedures

      • What’s New in Creating and Managing Stored Procedures

      • Advantages of Stored Procedures

      • Creating Stored Procedures

      • Executing Stored Procedures

      • Deferred Name Resolution

      • Viewing Stored Procedures

      • Modifying Stored Procedures

      • Using Input Parameters

      • Using Output Parameters

      • Returning Procedure Status

      • Debugging Stored Procedures Using SQL Server Management Studio

      • Using System Stored Procedures

      • Startup Procedures

      • Summary

    • 29 Creating and Managing User-Defined Functions

      • What’s New in SQL Server 2008

      • Why Use User-Defined Functions?

      • Types of User-Defined Functions

      • Creating and Managing User-Defined Functions

      • Rewriting Stored Procedures as Functions

      • Creating and Using CLR Functions

      • Summary

    • 30 Creating and Managing Triggers

      • What’s New in Creating and Managing Triggers

      • Using DML Triggers

      • Using DDL Triggers

      • Using CLR Triggers

      • Using Nested Triggers

      • Using Recursive Triggers

      • Summary

    • 31 Transaction Management and the Transaction Log

      • What’s New in Transaction Management

      • What Is a Transaction?

      • How SQL Server Manages Transactions

      • Defining Transactions

      • Transactions and Batches

      • Transactions and Stored Procedures

      • Transactions and Triggers

      • Transactions and Locking

      • Coding Effective Transactions

      • Transaction Logging and the Recovery Process

      • Long-Running Transactions

      • Bound Connections

      • Distributed Transactions

      • Summary

    • 32 Database Snapshots

      • What’s New with Database Snapshots

      • What Are Database Snapshots?

      • Limitations and Restrictions of Database Snapshots

      • Copy-on-Write Technology

      • When to Use Database Snapshots

      • Setup and Breakdown of a Database Snapshot

      • Reverting to a Database Snapshot for Recovery

      • Setting Up Snapshots Against a Database Mirror

      • Database Snapshots Maintenance and Security Considerations

      • Summary

    • 33 Database Maintenance

      • What’s New in Database Maintenance

      • The Maintenance Plan Wizard

      • Managing Maintenance Plans Without the Wizard

      • Executing a Maintenance Plan

      • Maintenance Without a Maintenance Plan

      • Database Maintenance Policies

      • Summary

  • Part V: SQL Server Performance and Optimization

    • 34 Data Structures, Indexes, and Performance

      • What’s New for Data Structures, Indexes, and Performance

      • Understanding Data Structures

      • Database Files and Filegroups

      • Database Pages

      • Space Allocation Structures

      • Data Compression

      • Understanding Table Structures

      • Understanding Index Structures

      • Data Modification and Performance

      • Index Utilization

      • Index Selection

      • Evaluating Index Usefulness

      • Index Statistics

      • SQL Server Index Maintenance

      • Index Design Guidelines

      • Indexed Views

      • Indexes on Computed Columns

      • Filtered Indexes and Statistics

      • Choosing Indexes: Query Versus Update Performance

      • Identifying Missing Indexes

      • Identifying Unused Indexes

      • Summary

    • 35 Understanding Query Optimization

      • What’s New in Query Optimization

      • What Is the Query Optimizer?

      • Query Compilation and Optimization

      • Query Analysis

      • Row Estimation and Index Selection

      • Join Selection

      • Execution Plan Selection

      • Query Plan Caching

      • Other Query Processing Strategies

      • Parallel Query Processing

      • Common Query Optimization Problems

      • Managing the Optimizer

      • Summary

    • 36 Query Analysis

      • What’s New in Query Analysis

      • Query Analysis in SSMS

      • SSMS Client Statistics

      • Using the SET SHOWPLAN Options

      • Using sys.dm_exec_query_plan

      • Query Statistics

      • Query Analysis with SQL Server Profiler

      • Summary

    • 37 Locking and Performance

      • What’s New in Locking and Performance

      • The Need for Locking

      • Transaction Isolation Levels in SQL Server

      • The Lock Manager

      • Monitoring Lock Activity in SQL Server

      • SQL Server Lock Types

      • SQL Server Lock Granularity

      • Lock Compatibility

      • Locking Contention and Deadlocks

      • Table Hints for Locking

      • Optimistic Locking

      • Summary

    • 38 Database Design and Performance

      • What’s New in Database Design and Performance

      • Basic Tenets of Designing for Performance

      • Logical Database Design Issues

      • Denormalizing a Database

      • Database Filegroups and Performance

      • RAID Technology

      • SQL Server and SAN Technology

      • Summary

    • 39 Monitoring SQL Server Performance

      • What’s New in Monitoring SQL Server Performance

      • Performance Monitoring Tools

      • A Performance Monitoring Approach

      • Summary

    • 40 Managing Workloads with the Resource Governor

      • Overview of Resource Governor

      • Resource Governor Components

      • Configuring Resource Governor

      • Monitoring Resource Usage

      • Modifying Your Resource Governor Configuration

      • Summary

    • 41 A Performance and Tuning Methodology

      • The Full Architectural Landscape

      • Primary Performance and Tuning Handles

      • A Performance and Tuning Methodology

      • Performance and Tuning Design Guidelines

      • Tools of the Performance and Tuning Trade

      • Summary

  • Part VI: SQL Server Application Development

    • 42 What’s New for Transact-SQL in SQL Server 2008

      • MERGE Statement

      • Insert over DML

      • GROUP BY Clause Enhancements

      • Variable Assignment in DECLARE Statement

      • Compound Assignment Operators

      • Row Constructors

      • New date and time Data Types and Functions

      • Table-Valued Parameters

      • Hierarchyid Data Type

      • Using FILESTREAM Storage

      • Sparse Columns

      • Spatial Data Types

      • Change Data Capture

      • Change Tracking

      • Summary

    • 43 Transact-SQL Programming Guidelines, Tips, and Tricks

      • General T-SQL Coding Recommendations

      • General T-SQL Performance Recommendations

      • T-SQL Tips and Tricks

      • In Case You Missed It: New Transact-SQL Features in SQL Server 2005

      • The xml Data Type

      • The max Specifier

      • TOP Enhancements

      • The OUTPUT Clause

      • Common Table Expressions

      • Ranking Functions

      • PIVOT and UNPIVOT

      • The APPLY Operator

      • TRY...CATCH Logic for Error Handling

      • The TABLESAMPLE Clause

      • Summary

    • 44 Advanced Stored Procedure Programming and Optimization

      • T-SQL Stored Procedure Coding Guidelines

      • Using Cursors in Stored Procedures

      • Nested Stored Procedures

      • Using Temporary Tables in Stored Procedures

      • Using Remote Stored Procedures

      • Stored Procedure Performance

      • Using Dynamic SQL in Stored Procedures

      • Installing and Using .NET CLR Stored Procedures

      • Using Extended Stored Procedures

      • Summary

    • 45 SQL Server and the .NET Framework

      • What’s New in SQL Server 2008 and the .NET Framework

      • Getting Comfortable with ADO.NET 3.5 and SQL Server 2008

      • Developing with LINQ to SQL

      • Using ADO.NET Data Services

      • Leveraging the Microsoft Sync Framework

      • Summary

    • 46 SQLCLR: Developing SQL Server Objects in .NET

      • What’s New for SQLCLR in SQL Server 2008

      • Developing Custom Managed Database Objects

      • Summary

    • 47 Using XML in SQL Server 2008

      • What’s New in Using XML in SQL Server 2008

      • Understanding XML

      • Relational Data As XML: The FOR XML Modes

      • XML As Relational Data: Using OPENXML

      • Using the xml Data Type

      • Indexing and Full-Text Indexing of xml Columns

      • Summary

    • 48 SQL Server Web Services

      • What’s New in SQL Server Web Services

      • Web Services Migration Path

      • Web Services History and Overview

      • Building Web Services

      • Examples: A C# Client Application

      • Using Catalog Views and System Stored Procedures

      • Controlling Access Permissions

      • Summary

    • 49 SQL Server Service Broker

      • What’s New in Service Broker

      • Understanding Distributed Messaging

      • Designing a Sample System

      • Understanding Service Broker Constructs

      • Service Broker Routing and Security

      • Troubleshooting SSB Applications with ssbdiagnose.exe

      • Related System Catalogs

      • Summary

    • 50 SQL Server Full-Text Search

      • What’s New in SQL Server 2008 Full-Text Search

      • Upgrade Options in SQL Server 2008

      • How SQL Server FTS Works

      • Implementing SQL Server 2008 Full-Text Catalogs

      • Setting Up a Full-Text Index

      • Full-Text Searches

      • Full-Text Search Maintenance

      • Full-Text Search Performance

      • Full-Text Search Troubleshooting

      • Summary

  • Part VII: SQL Server Business Intelligence Features

    • 51 SQL Server 2008 Analysis Services

      • What’s New in SSAS

      • Understanding SSAS and OLAP

      • Understanding the SSAS Environment Wizards

      • An Analytics Design Methodology

      • An OLAP Requirements Example: CompSales International

      • Summary

    • 52 SQL Server Integration Services

      • What’s New with SSIS

      • SSIS Basics

      • SSIS Architecture and Concepts

      • SSIS Tools and Utilities

      • A Data Transformation Requirement

      • Running the SSIS Wizard

      • The SSIS Designer

      • The Package Execution Utility

      • Connection Projects in Visual Studio

      • Change Data Capture Addition with R2

      • Using bcp

      • Logged and Nonlogged Operations

      • Summary

    • 53 SQL Server 2008 Reporting Services

      • What’s New in SSRS 2008

      • Reporting Services Architecture

      • Installing and Configuring SSRS

      • Developing Reports

      • Management and Security

      • Performance and Monitoring

      • Summary

  • Part VIII: Bonus Chapters

    • 54 Managing Linked and Remote Servers

      • What’s New in Managing Linked and Remote Servers

      • Managing Remote Servers

      • Linked Servers

      • Adding, Dropping, and Configuring Linked Servers

      • Mapping Local Logins to Logins on Linked Servers

      • Obtaining General Information About Linked Servers

      • Executing a Stored Procedure via a Linked Server

      • Setting Up Linked Servers Using SQL Server Management Studio

      • Summary

    • 55 Configuring, Tuning, and Optimizing SQL Server Options

      • What’s New in Configuring, Tuning, and Optimizing SQL Server Options

      • SQL Server Instance Architecture

      • Configuration Options

      • Fixing an Incorrect Option Setting

      • Setting Configuration Options with SSMS

      • Obsolete Configuration Options

      • Configuration Options and Performance

      • Database Engine Tuning Advisor

      • Data Collection Sets

      • Summary

    • 56 SQL Server Disaster Recovery Planning

      • What’s New in SQL Server Disaster Recovery Planning

      • How to Approach Disaster Recovery

      • Microsoft SQL Server Options for Disaster Recovery

      • The Overall Disaster Recovery Process

      • Have You Detached a Database Recently?

      • Third-Party Disaster Recovery Alternatives

      • Summary

  • Index

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    • J

    • K

    • L

    • M

    • N

    • O

    • P

    • Q

    • R

    • S

    • T

    • U

    • V

    • W

    • X

    • Y-Z

Nội dung

ptg 2074 CHAPTER 51 SQL Server 2008 Analysis Services If you want much more drill-up and drill-down visibility into your data, you could build up a much more complicated representation in the data browser. Say that you want to see sales units and sales returns but across the full product dimension breakouts and full time dimension breakouts for the United States geographic region only. You also want to see all dimension levels, totals by levels, and grand totals by dimension. You start the same way as you did earlier and expand out the measures object until you see all the detail measures in the Comp Sales cube. If you still have the previous example in your data browser, you can simply locate the Clear Results icon in the data browser tab and clear the data browser pane. Then you drag Sales Units to the center of the lower portion of the data browsing pane (into the Drop Totals or Detail Fields Here section in the lower right). You do the same for the Sales Returns measure. Then you drag the geography dimension to the upper section called Select Dimensions or just highlight Select Dimensions and choose the geog- raphy dimension. This is the dimension-level filtering capability within the data browser. You now just select (via the drop-downs of each section within a filter specification) the level and type of filtering you want to do for the dimension you are working with. You can specify any number of filters within any number of dimensions. To just filter on coun- tries within the geography dimension, you select Countries within the hierarchies list of the geography dimension, and the operator you want is Equal, and the filter expression is the data value that you want to filter on (the United States country value, in this case). These are all drop-down lists that you can easily select by either clicking the entry or indi- cating which ones to use via a check box entry. Figure 51.48 shows the fully specified Geo Dimension filter specified. FIGURE 51.48 Complex data browsing with full dimensions and filtering in the SMSS data browser. ptg 2075 An OLAP Requirements Example: CompSales International 51 The data values you now see are only those of the United States. You now drag the product dimension object to the Drop Column Fields Here section (just above where the data measures were dropped). You immediately see the data measure values being broken out by the entire product dimension (you expand the plus sign of the product hierarchy all the way out to the SKU level). Then you drag the time dimension object to the Drop Row Fields Here section (just to the left of where the data measures were dropped). You can choose to view the data at any level within either the time or product hierarchies, and you can filter on any other dimension values. You can also just add a dimension or dimension level to the filter portion within the data browser or just drag off dimensions, measures, or filters from the data browser if you don’t want to use them anymore. This is very easy indeed. The cube browser shows you what your cube has in it and also illustrates the utility of a dimensional database. Users can easily analyze data in meaningful ways. SSAS allows you to browse individual dimension member data. You just right-click any dimension in the left pane of SSMS (for example, the time dimension) and choose Browse. As you can see in Figure 51.49, the dimension browser opens with All as the top node in the dimension. You simply expand the levels to see the actual member values within this cube dimension. Expanding each level gets you to more detailed information as you move down the dimension hierarchy. FIGURE 51.49 Browsing the Time dimension using SSMS. ptg 2076 CHAPTER 51 SQL Server 2008 Analysis Services Delivering Data to Users SSAS provides a great deal of flexibility for building scalable OLAP solutions, but how do you present the data to users? The client-side components deliver much of the functional- ity of SSAS, using the same code base for the dimensional calculation engine, caching, and query processing. You can use the Pivot Table Service to manage client/server connec- tions, and this is the layer for user interfaces to access SSAS cubes through the OLE DB for OLAP interface. ADO MD provides an application-level programming interface for devel- opment of OLAP applications. Third-party tools and future versions of Microsoft Excel (like 2007 and 2010) and other Microsoft Office products will use the Pivot Table Service to access cubes. The underlying Pivot Table Service shares metadata with SSAS, so a request for data on the client causes data and metadata to be downloaded to the client. The Pivot Table Service determines whether requests need to be sent to the server or can be satisfied at the client with downloaded data. If a user requests sales information for the first quarter of 2008 and then later decides to query that data for the first quarter of 2007 for comparison, only the request for 2007 data has to go to the server to get more data. The 2008 data is cached on the client. Slices of data that are retrieved to the client computer can also be saved locally for analysis when the client computer is disconnected from the network. Users can download the data in which they are interested and analyze it offline. The Pivot Table Service can also create simple OLAP databases by accessing OLE DB–compliant data sources. With the ADO MD interface, developers will be able to access and manipulate objects in an SSAS database, enabling web-based OLAP application development. Many independent software vendors, such as Brio, Cognos, Business Objects, Micro Strategies, and Hyperion, are working with Microsoft to leverage the rich features of these OLAP services. They offer robust user interfaces that can access SSAS’s cubes. Versions of Microsoft Office include the Pivot Table Service to enable built-in analysis in tools such as Excel. It is getting easier and easier to bring OLAP to the masses. Multidimensional Expressions The OLE DB for OLAP specification contains MDX syntax that is used to build datasets from cubes and is used to define cubes themselves. Developers of OLE DB OLAP providers can map MDX syntax to SQL statements or native query languages of other OLAP servers, depending on the storage techniques. MDX statements build datasets by using information about cubes from which the data will be read. This includes the number of axes to include, the dimensions on each axis and the level of nesting, the members or member tuples and sort order of each dimension, and the dimension members used to filter, or slice, the data. (Tuples are combinations of dimensions such as time and product time that present multidimensional data in a two- dimensional dataset.) An MDX statement has four basic parts: . Member scope information, using the WITH MEMBER clause ptg 2077 An OLAP Requirements Example: CompSales International 51 . Dimension, measure, and axis information in the SELECT clause . The source cube in the FROM clause . Dimension slicing in the WHERE clause Expressions in an MDX statement operate on numbers, strings, members, tuples, and sets. Numbers and strings mean the same thing here as they do in other programming contexts. Members are the values in a dimension, and levels are groups of members. Sets are collec- tions of tuple elements to further combine facts. If the dimension were time, a particular year, quarter, or month would be a member, and month values would belong to the month level. You use the dimension browser in SSAS to view members of a dimension. The following example shows an MDX SQL expression: WITH MEMBER [Measures].[Total Sales Units] AS ‘Sum([Measures].[Sales Units])’ SELECT {[Measures].[Total Sales Units]} ON COLUMNS, {Topcount([Product_Dimension].[SKU].members,100, [Measures].[Total Sales Units])} ON ROWS FROM [Comp Sales] WHERE ([Time_Dimension].[All Time]) You can download this simple query against the Comp Sales cube from Sams Publishing at www.samspublishing.com, and it is on the CD for this book as well. This query returns the sums of the sales units for products for all time periods. Figure 51.50 shows the full execu- tion of this query within a query window of SSMS. Notice that the metadata for the cube is also made available in the center pane of SSMS, along with an MDX Functions tab that provides all the MDX functions that can be used. This feature is very helpful for building valid MDS queries within this environment. Also notice that the result set display area is very specialized in order to display multidimensional results. This simple MDX statement shows the basic parts of a working query. In this case, measures are displayed in columns, and the product dimension members make up the axes of this multidimensional query and are displayed in rows. The display of multiple dimensions in rows like this is how the term tuple is used in the context of SSAS. Much more could be said about MDX syntax, and a complete discussion of MDX could fill its own chapter. For more information, see the OLE DB for OLAP Programmers Reference, which is available on the Microsoft website at http://msdn2.microsoft.com/en-us/library/ ms145506.aspx. It contains detailed information about MDX expressions and grammar. ADO MD ADO MD is an easy-to-use access method for dimensional data via an OLE DB for OLAP provider. You can use ADO MD in Visual Basic, Visual C++, and Visual J++. Like ADO, ADO MD offers a rich application development environment that can be used for multi- tier client/server and web application development. ptg 2078 CHAPTER 51 SQL Server 2008 Analysis Services FIGURE 51.50 Comp Sales MDX query execution in SSMS. You can retrieve information about a cube, or metadata, and execute MDX statements by using ADO MD to create cellsets to return interesting data to a user. ADO MD is another subject too broad to cover in detail in this chapter. Specifications for OLE DB for OLAP and ADO MD are available on the Microsoft website at http://msdn2.microsoft.com/en-us/ library/ms126037.aspx. Calculated Members (Calculations) Remember from the Comp Sales requirements that there was an additional user need to see the difference between sales units and sales returns (sales units minus sales returns) to yield net sales. One approach is to use the SSAS calculated members (calculations) capabil- ity. This creates an expression against existing measures that will be treated the same as a measure. Basically, you need to complete the requirements for the Comp Sales cube by adding a calculation measure to this cube for net sales units. To create a calculation, you go back to Visual Studio and the cube designer. Then you click the Calculations tab and create a new calculation measure called Sales Units NET with the calculation expression of (Sales Units - Sales Returns), as shown in Figure 51.51. Many functions are available for use that should meet your individual calculation needs. This calculation fulfills the data measure requirements of Comp Sales. All that is left to do is to process the cube so others can use it. The following sample MDX query uses the newly created calculation measure: WITH MEMBER [Measures].[Total Sales Units NET] AS ‘Sum([Measures].[Sales Units NET])’ ptg 2079 An OLAP Requirements Example: CompSales International 51 FIGURE 51.51 A new calculation measure of Sales Units NET in the Visual Studio cube designer. Figure 51.52 shows this new calculation measure listed in the cube’s metadata pane. You can see how easy it is to use in the cube data browser. You might want to check the math, however, to make sure the calculation is correct. Query Analysis and Optimization In SSAS, you can look at query utilization and performance in a cube. You can look at queries by user, frequency, and execution time to determine how to better optimize aggre- gations. If a slow-running query is used frequently by many users, or by the CEO, it might be a good candidate for individual tuning. A usage-based analysis capability can be used to change aggregations based on actual live queries that the cube must service. This adjusts aggregations based on a query to reduce response time. You start this wizard by right-clicking the cube’s partition. Figure 51.53 shows the Usage-Based Optimization Wizard splash page. The Usage-Based Optimization Wizard allows you to filter queries by user, frequency of execution, time frame, and execution time. You see a record for each query you have run since the date you began, the number of times it was executed, and the average execution time, in seconds. This is like a SQL trace analysis of your OLAP queries. SELECT {[Measures].[Total Sales Units NET]} ON COLUMNS, {Topcount([Product_Dimension].[SKU].members,100, [Measures].[Total Sales Units NET])} ON ROWS FROM [Comp Sales] WHERE ([Time_Dimension].[All Time]) ptg 2080 CHAPTER 51 SQL Server 2008 Analysis Services FIGURE 51.52 Data browsing using the Sales Units NET calculation in the Visual Studio cube designer data browser. FIGURE 51.53 The Usage-Based Optimization Wizard. ptg 2081 An OLAP Requirements Example: CompSales International 51 Because aggregations already exist, the wizard asks whether you want to replace them or add new ones. If you replace the existing aggregations, the cube is reprocessed with this particular query in mind. Generating a Relational Database The examples you have worked with up to this point have been from a dimensional data- base that uses a star or snowflake schema (the CompSales database). Very often, however, you create cubes based on requirements only and do not have an existing data source (or sources) to draw on at design time. After you complete your cube design, you can choose to generate a relational schema that can be used to retain (that is, stage) the cube’s source data or that can be a data warehouse/data mart unto itself. Figure 51.54 shows the start of the Schema Generation Wizard for building a data warehouse/staging database from the top down. FIGURE 51.54 Generating a relational schema from the cube and dimension definitions. ptg 2082 CHAPTER 51 SQL Server 2008 Analysis Services NOTE Designing dimensional databases is an art form and requires not only sound dimen- sional modeling knowledge, but also knowledge of the business processes with which you are dealing. Data warehousing has several design approaches. Regardless of which approach you take, having a good understanding of the approach’s design tech- niques is critical to the success of a data warehouse project. Although Microsoft pro- vides a powerful set of tools to implement data marts, astute execution of design methods is critical to getting the correct data—the truly business-significant business data—to the end users. Limitations of a Relational Database Even using a tool such as SSAS, you face limitations when dealing with a normalized data- base. Using a view can often solve (or mask) these issues. In some cases, however, more complicated facts and dimensions might require denormalized tables or a dimensional database in the storage component of the data warehouse to bring information together. Data cleansing and transformation are also major considerations before you attempt to present decision makers with data from OLTP systems. Cube Perspectives A new feature in SSAS is cube perspectives. This is essentially a way to create working views of a complex cube that is focused on just what a particular user or group of users need. They don’t need all the dimensions, calculations, levels, and key performance indi- cators (KPIs) that would otherwise be visible as part of a complex SSAS cube. Therefore, you need a method to tailor or limit a larger cube environment to be just what the users need and nothing more—hence, the cube perspective. Figure 51.55 shows the Perspectives tab in the cube designer. It allows you to easily customize a view (perspective), which is what will be deployed or referenced to a target user group. In this example, you are creat- ing a new perspective called Comp Sales wo Sales Price, which excludes the extremely sensitive Sales Price data measure from any user given access to this perspective. You can have any number of perspectives on a cube. Figure 51.56 shows what a cube user sees when trying to browse (or access) cube data via a perspective. Using perspectives is a great way to simplify the user’s life in an already-complicated OLAP world. KPIs Figure 51.57 shows another new capability in SSAS: creating embedded KPIs. Just like calculations, KPIs allow you to define thresholds, goals, status indications, and trend expressions that become part of an OLAP cube. Each can then be graphically displayed in a variety of ways (for example, gauges, thermometers, traffic lights, trend indications such as up arrows, smiling faces). This is perfect for an executive dashboard or portal imple- mentation that has its basis in an SSAS cube. You can easily access KPIs via the cube ptg 2083 An OLAP Requirements Example: CompSales International 51 FIGURE 51.55 Creating cube perspectives within SSAS in the cube designer. FIGURE 51.56 Browsing cube data via a perspective in the cube designer. designer’s KPIs tab. What are you waiting for? It is pretty easyto create powerful KPIs with this simple yet rich interface. Data Mining With SSAS, a much more robust selection of capabilities for data mining is available Data mining is the process of understanding potentially undiscovered characteristics or distributions of data. Data mining can be extremely useful for OLAP database design in that patterns or values might define different hierarchy levels or dimensions that were not . development environment that can be used for multi- tier client /server and web application development. ptg 2078 CHAPTER 51 SQL Server 2008 Analysis Services FIGURE 51.50 Comp Sales MDX query execution. dimension hierarchy. FIGURE 51.49 Browsing the Time dimension using SSMS. ptg 2076 CHAPTER 51 SQL Server 2008 Analysis Services Delivering Data to Users SSAS provides a great deal of flexibility. ptg 2074 CHAPTER 51 SQL Server 2008 Analysis Services If you want much more drill-up and drill-down visibility into your

Ngày đăng: 05/07/2014, 02:20