Module 10 Designing SQL Server 2008 Components

42
Module 10 Designing SQL Server 2008 Components

description

Module 10 Designing SQL Server 2008 Components. Module Overview. Overview of SQL Server 2008 Components Designing a Service Broker Architecture Designing the Service Broker Data Flow Designing the Service Broker Availability Exploring Full-Text Search - PowerPoint PPT Presentation

Transcript of Module 10 Designing SQL Server 2008 Components

Page 1: Module 10 Designing SQL  Server 2008 Components

Module 10

Designing SQL Server 2008 Components

Page 2: Module 10 Designing SQL  Server 2008 Components

Module Overview

• Overview of SQL Server 2008 Components

• Designing a Service Broker Architecture

• Designing the Service Broker Data Flow

• Designing the Service Broker Availability

• Exploring Full-Text Search

• Designing a Full-Text Search Strategy

Page 3: Module 10 Designing SQL  Server 2008 Components

Lesson 1: Overview of SQL Server 2008 Components

• Overview of the SQL Server 2008 Architecture

• Considerations for Using Database Mail

• What Is a Distributed Query?

• Considerations for Using Linked Servers

• Demonstration: How To Set Up Linked Servers

Page 4: Module 10 Designing SQL  Server 2008 Components

Overview of the SQL Server 2008 Architecture

Sample Text

SampleComponents of SQL Server 2008

Database Engine

SQL Server Agent Analysis Services

Integration Services

Reporting Services

Service Broker

Page 5: Module 10 Designing SQL  Server 2008 Components

Considerations for Using Database Mail

Operating with the SQL Server database engine Using Simple Mail Transfer Protocol (SMTP) instead of Messaging

Application Programming Interface (MAPI) Implementing isolation and robustness Supporting clusters and 64-bit servers

Use Database Mail instead of another e-mail solution while:

Page 6: Module 10 Designing SQL  Server 2008 Components

Distributed queries are queries that access data from multiple heterogeneous data sources

What Is a Distributed Query?

Pass-through QueriesSends commands directly to an ODBC database server

Linked ServerEnables SQL Server to execute commands against OLE DB data sources on remote servers

Distributed Queries

Ad-hoc Queries Are not predefined queries and are accessed infrequently

Page 7: Module 10 Designing SQL  Server 2008 Components

Considerations for Using Linked Servers

Usage Considerations

• Security Context• Distributed Transactions• Clustered Environments

Linked servers are advantageous because they can:

• Access remote servers• Issue distributed queries, updates, commands, and transactions on

heterogeneous data sources across the enterprise• Address diverse data sources similarly

Page 8: Module 10 Designing SQL  Server 2008 Components

Demonstration: How To Set Up Linked Servers

In this demonstration, you will see how to:

Set up linked servers

Page 9: Module 10 Designing SQL  Server 2008 Components

Lesson 2: Designing a Service Broker Architecture

• Components of Service Broker

• Architecture of Service Broker Service

• Characteristics of a Service Broker Solution

• Considerations for Implementing a Service Broker Solution

• Process for Identifying Services

• Components of Service Broker Conversation

• Service Broker Conversation Process

• Considerations for Identifying Conversations

• Considerations for Designing Dialog Standards

• Considerations for Designing Queue Usage

Page 10: Module 10 Designing SQL  Server 2008 Components

Components of Service Broker

Component Description

Message types • Defines a name for a message type and defines the type of data that the message contains

• Definitions persist in the database where the message type is created

Contracts • Defines which message types an application uses to accomplish a particular task

• Is an agreement between two services about which messages each service sends to accomplish a particular task

Queues • Store messages that a Service broker receives for a service• Return messages in the order in which the sender sent the

message

Services • Is a name for a specific business task or set of business tasks• Allows Service Broker to deliver messages to the correct queue

within a database, to route messages, to enforce the contract for a conversation, and to determine the remote security for a new conversation

Page 11: Module 10 Designing SQL  Server 2008 Components

Architecture of Service Broker Service

ContractProcessExpenses ServiceProcessExpense

Message TypeSubmitExpense

(Initiator)

Message TypeAcceptDenyExpense

(Target)

Message TypeReimbursementIssued

(Target)

Service

Message

Message

Message

Message

Queue

Service Program

Contract

Message Type

Page 12: Module 10 Designing SQL  Server 2008 Components

Service Broker components have reliable fault tolerance

Characteristics of a Service Broker Solution

Service Broker delivers messages in the order that they were sent

Service Broker delivers a message only once

Service Broker supports asynchronous processing of multiple applications

Page 13: Module 10 Designing SQL  Server 2008 Components

Considerations for Implementing a Service Broker Solution

Consider the following when implementing a Service Broker solution:

Process tasks asynchronously

Process tasks in a specific order

Wait for another application before processing tasks Configure databases as broker instances Ensure fault tolerance

Service Broker Solution

Page 14: Module 10 Designing SQL  Server 2008 Components

Service Broker Services

Process tasks in parallelProcess tasks independently

Service Broker Services

A service is a named interface within a Service Broker solution that provides a structure for a set of business tasks

Service Broker Service

Process for Identifying Services

Identifying Services

Page 15: Module 10 Designing SQL  Server 2008 Components

Components of Service Broker Conversation

Component Description

Messages • Are the information exchanged between applications that use Service Broker

• Has a unique conversation identity, as well as a sequence number within the conversation

Dialog Conversations

• Is a reliable, persistent bidirectional stream of messages between two services

• Use the conversation identifier and sequence numbers that are contained in each message to identify related messages and deliver messages in the correct order

Conversation Groups

• Allows an application to easily coordinate conversations involved in a specific business task

• Provide exactly-once-in-order (EOIO) access to messages that are related to a specific business task

Conversation Priorities

• Are a set of user-defined rules, each of which specifies a priority level and the criteria for determining which Service Broker conversations to assign the priority level

Page 16: Module 10 Designing SQL  Server 2008 Components

Service Broker Conversation Process

ProcessExpense Contract

ExpenseClaim

Message Type (Initiator)

ClaimResponse

Message Type (Target)

ExpenseSubmission service program activated; conversation ends8

ExpenseClaim message

ClaimResponse message

ExpenseQueue queue ExpenseQueue queue

SubmitExpense Service ProcessExpense Service

msg msg

ExpenseResult Stored Procedure

SubmitExpenseStored Procedure

msg msg

ProcessExpenseStored Procedure

1

2

8 6 4

5

3

7

Page 17: Module 10 Designing SQL  Server 2008 Components

Service Broker Components

Considerations for Identifying Conversations

• An application initiates a conversation• A conversation is a named, two-way dialog

between two services• The BEGIN DIALOG CONVERSATION

statement initiates a conversation• The SEND statement sends a message

Service Broker Conversations

Considerations for Identifying Service Broker Conversations

• Establish communication between services• Initiate a dialog between services

Page 18: Module 10 Designing SQL  Server 2008 Components

Deliver messages in the correct order End conversations manually

END CONVERSATIONS

Set the time-out period Maintain conversation sessions

Considerations for Designing Dialog Standards

Page 19: Module 10 Designing SQL  Server 2008 Components

Considerations for Designing Queue Usage

Considerations for Designing Queue Usage

Store messages for a service Enable message retention Process groups of messages Disable unused queues

Service Broker Solution

Page 20: Module 10 Designing SQL  Server 2008 Components

• Process for Designing the Service Broker Data Flow

• Considerations for Identifying Conversation Groups

• Considerations for Identifying Service Routes

• Considerations for Identifying Service Activation Methods

Lesson 3: Designing the Service Broker Data Flow

Page 21: Module 10 Designing SQL  Server 2008 Components

Process for Designing the Service Broker Data Flow

Define how Service Broker validates messages

Check contract specifications

Specify the message order

Identify messages for parallel processing

Specify the message lifetime

Page 22: Module 10 Designing SQL  Server 2008 Components

Apply locks to conversation groups

Considerations for Identifying Conversation Groups

Determine the message order

Page 23: Module 10 Designing SQL  Server 2008 Components

Considerations for Identifying Service Routes

Store routing information in multiple places

Use service route names

Expose Service Broker endpoints

Use intermediary broker instances to forward messages

Use routing to scale out your applications

Secure your routes

Page 24: Module 10 Designing SQL  Server 2008 Components

External Program

Considerations for Identifying Service Activation Methods

Determining Whether to Activate the Queues

Activating the Queues Externally

Queue

Service Broker

Page 25: Module 10 Designing SQL  Server 2008 Components

Lesson 4: Designing the Service Broker Availability

• Designing Service Broker Fault Tolerance

• Designing a Service Broker Backup Strategy

Page 26: Module 10 Designing SQL  Server 2008 Components

Designing Service Broker Fault Tolerance

Service Broker

Set up database mirrors

Create server clusters

Evaluate the effects on performance

Page 27: Module 10 Designing SQL  Server 2008 Components

Designing a Service Broker Backup Strategy

Back up databases

Create a recovery plan to restore data

Back up and restore external applications

Create Transact-SQL script files

Page 28: Module 10 Designing SQL  Server 2008 Components

Lesson 5: Exploring Full-Text Search

• Overview of Full-Text Search

• Role of the Full-Text Engine

• Process of Full-Text Indexing and Querying

Page 29: Module 10 Designing SQL  Server 2008 Components

Overview of Full-Text Search

1. Create a full-text catalog2. Create a full-text index on each table that you want to search

• Simple terms: One or more specific words or phrases• Prefix terms: A word or a phrase where the words begin with

specified text• Generation terms: Inflectional forms of a specific word• Proximity terms: A word or phrase close to another word or

phrase

• Thesaurus: Synonymous forms of a specific word• Weighted terms: Words or phrases using weighted values

To configure a database for full-text searching:

Full-text queries can search for:

Page 30: Module 10 Designing SQL  Server 2008 Components

Role of the Full-Text Engine

QueryingIndexing

Full-Text Engine

Page 31: Module 10 Designing SQL  Server 2008 Components

Process of Full-Text Indexing and Querying

Indexing Process

(…)

Full-Text Engine

Full-Text EngineQuery Processor

Querying Process

Host

Word ListFull-Text Search

Inverted Indexes

Full-Text Portions: SQL Operators

Client

Alert

Word Breaking

Page 32: Module 10 Designing SQL  Server 2008 Components

Lesson 6: Designing a Full-Text Search Strategy

• Overview of Full-Text Search Predicates and Functions

• Considerations for Designing Full-Text Search Predicates and Functions

• Considerations for Designing Full-Text Search Performance

• Gathering Information Through Full-Text Search

• Demonstration: How to Create a Full-Text Catalog

• Demonstration: How to Perform Full-Text Search

Page 33: Module 10 Designing SQL  Server 2008 Components

• Combine several search terms to perform logical operations • AND searches for all the terms• OR searches for either of the terms• AND NOT excludes a term from the search

Boolean operators:

Overview of Full-Text Search Predicates and Functions

• Return a TRUE or FALSE value• Specify selection criteria for matching rows to a full-text query• CONTAINS searches for precise or fuzzy matches• FREETEXT searches for words matching the word meaning

CONTAINS FREETEXTFull-text predicates:

• Referenced in the FROM clause of a SELECT statement • Specify the base table to be full-text searched • The KEY column returns unique values of the returned rows• The RANK column returns a rank value for each row

Full-text functions:

(…) RANK

KEY

CONTAINSTABLE

FREETEXTTABLE

Page 34: Module 10 Designing SQL  Server 2008 Components

Considerations for Designing Full-Text Search Predicates and Functions

When designing full-text search predicates and functions, you can:

• Search for specific word or phrase• Perform prefix searches• Search for the inflectional form of a

specific word• Search for words or phrases close to

another word or phrase• Limit ranked result setsFull-Text Search Functions

(…)

CONTAINS

FREETEXT

CONTAINSTABLEFREETEXTTABLE

Page 35: Module 10 Designing SQL  Server 2008 Components

Considerations for Designing Full-Text Search Performance

• Defragment the index of the base table

• Reorganize the full-text catalog

• Use a small full-text key column

• Use an integer full-text key

• Combine multiple CONTAINS predicates

• Use CONTAINSTABLE for rank or key information

• Choose an appropriate join plan for the full-text query

• Reorganize full-text catalogs to reduce fragmentation

• Frame queries by using a single logical operator

• Use query optimizer to exploit predicate or range pushdown

• Use the top_n_by_rank parameter to increase performance

Page 36: Module 10 Designing SQL  Server 2008 Components

Gathering Information Through Full-Text Search

Choose a filegroupfor a full-text index

Update the full-text index

Assign the full-text index to a full-text catalog

Associate a stoplist with the full-text index

To set up full-text indexing capability:

1. Create a full-text catalog to store full-text indexes

2. Create a full-text index on the table or indexed view

Page 37: Module 10 Designing SQL  Server 2008 Components

Demonstration: How To Create a Full-Text Catalog

In this demonstration, you will see how to:

Create a full-text catalog

Page 38: Module 10 Designing SQL  Server 2008 Components

Demonstration: How To Perform Full-Text Search

In this demonstration, you will see how to:

Perform full-text search

Page 39: Module 10 Designing SQL  Server 2008 Components

Lab 10: Designing SQL Server 2008 Components

• Exercise 1: Analyzing the Organizational Needs • Exercise 2: Designing a Service Broker Solution Model • Exercise 3: Designing a Detailed Service Broker Solution• Exercise 4: Implementing the Service Broker Solution

Estimated time: 60 minutes

Logon Information

Virtual machine

User name

Password

NYC-SQL1

Administrator

Pa$$w0rd

Page 40: Module 10 Designing SQL  Server 2008 Components

Lab Scenario

You are a lead database designer at QuantamCorp. QuantamCorp manufactures and sells metal and composite bicycles to North American, European, and Asian commercial markets. The organization has its base operation with 290 employees at Bothell, Washington, and several regional sales teams throughout their market base.

After completing a successful fiscal year, QuantamCorp is now looking to broaden its market share by targeting their sales to their best customers, extending their product availability through an external Web site, and reducing their cost of sales through lower production costs.

QuantamCorp wants to ensure that addressing and pricing information is synchronized between the central office and the branch offices. You need to implement processes to handle the following events:

• Customer address information changes at the branch office. A stored procedure in the branch office database should write the changes to that database and then send a message with the updated address information to the central office database. A stored procedure in the central office database should receive the message, update that database, and then send a message with the updated address information to the other branch office databases.

• Item pricing information changes at the central office. A stored procedure in the central office database should write changes to that database and then send a message with the updated item pricing information to the branch office databases.

The management has decided to invest on SQL Server 2008. In this lab, you will evaluate the business requirements of your organization and identify the appropriate SQL Server services to meet the requirements. In addition, you will implement a Service Broker solution.

Page 41: Module 10 Designing SQL  Server 2008 Components

Lab Review

• What are the steps necessary to create a Service Broker solution?• What is a poison message?• How can you activate a Service Broker?• Should you use a single queue or multiple queues to send

messages to the branch office databases? • How can you prioritize price update messages over address

update messages in the branch offices?

Page 42: Module 10 Designing SQL  Server 2008 Components

Module Review and Takeaways

• Review Questions

• Real-world Issues and Scenarios • Best Practices for Service Broker