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

Instructor Inputs - Session 14 pot

26 97 0
Tài liệu đã được kiểm tra trùng lặp

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

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 26
Dung lượng 1,02 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

1.0 Querying and Managing Data Using SQL Server 2005 In this session, you will learn to: Understand managed code Create managed database objects Define the Hypertext Transfer Protocol en

Trang 1

Instructor Inputs S e

Trang 3

¤NIIT Instructor Inputs 14.3

This session includes Chapter 9 and Chapter 10 of the Student Guide

Slide 1

Slide 1 of 31 Session 14

Ver 1.0

Querying and Managing Data Using SQL Server 2005

In this session, you will learn to:

Understand managed code Create managed database objects Define the Hypertext Transfer Protocol endpoints Implement the Hypertext Transfer Protocol endpoints for Web services

Objectives

Start the session by sharing the objectives with the students In this session, the students

will learn the importance of managed objects and how to create them In addition, they

will also learn how to implement Web services in SQL Server 2005 using HTTP

endpoints

Session Overview

Trang 4

Slide 2

Slide 2 of 31 Session 14

Introduction to SQL Server CLR Integration

In this topic, you need to explain the students about CLR As they have already read about CLR in the chapter 1, you need not to go into the details of CLR

Explain how CLR has been incorporated in the SQL Server itself Also explain the benefits of integrating CLR inside SQL Server itself You can use the examples provided

in the Student Guide to clarify the concept to the students

T-SQL has been the conventional language to write database objects, such as stored procedure, triggers and functions SQL Server 2005 provides the new possibilities to the database developer by integrating NET Framework in it SQL Server 2005 allows the database developers to write stored procedures, triggers, user-defined types, user-defined aggregates, and user-defined functions in any of the NET supported language, build a dll, register and use it inside a SQL Server

It is very important that the students understand that you are not removing the business or data layer by hosting the C# code in the SQL Server SQL Server is still a database and is not intended to be used as an application server in your architecture

Trang 5

¤NIIT Instructor Inputs 14.5

Slide 3

Slide 3 of 31 Session 14

Ver 1.0

Querying and Managing Data Using SQL Server 2005

Managed database objects can be created in the following situations:

To implement complicated programming logics

To access external resources

To implement a CPU-intensive functionality that can run more efficiently as compared to the managed code.

T-SQL statements can be used in the following situations:

To perform data access and manipulation operations that can

be done using the T-SQL statements.

To implement programming logic tat can be easily implemented using T-SQL programming constructs.

Identifying the Need for Managed Code

In this topic, you need to explain the need for managed code to the students You need to

explain the limitations of T-SQL to the students, and how those limitations can be

overcome by introducing managed code in SQL Server

T-SQL is a language that is used to manipulate and query data from a database server It

provides a number of database features, such as query plans and caching of query plans

and their results Because of all these features, T-SQL is the best choice for the operations

in the SQL Server But the procedural aspect of T-SQL makes it complicate to use in

situations that involve functions such as, complex mathematical computations, recursive

operations, and heavily procedural

In addition, T-SQL can not take the advantage of code reuse If you try to implement all

this using T-SQL, the network traffic of your company goes into a loop and results in

slow query processing With the ability to write and host NET code inside SQL Server

2005, you now can prevent the network roundtrips and host the necessary NET code right

inside SQL Server

Trang 6

Slide 4

Slide 4 of 31 Session 14

Let’s see how…

Importing and Configuring Assemblies

In this topic, you need to explain the concept of assemblies to the students In addition, you also need to teach how to import the NET assembly inside the SQL Server To clarify the concept, you may provide the students with the example provided in the Student Guide

Trang 7

¤NIIT Instructor Inputs 14.7

The students have learned about the assemblies in NET framework To clarify the doubts

of the students, you can specify that the assemblies in NET are the dll or exe files that

have provide a specific functionality In SQL Server 2005, an assembly is a database

object that stores the code of NET assembly

Slide 6

Slide 6 of 31 Session 14

Ver 1.0

Querying and Managing Data Using SQL Server 2005

Managed database objects can be of the following types:

Stored Procedures Functions Triggers UDTs

Creating Managed Database Objects

Trang 8

Note

In this topic, you need to explain the various types of managed database objects that can

be created in SQL Server As students are already aware of these all database objects, you need not differentiate between them

In the following topics, you will show examples given in the Student Guide to

demonstrate how to create different types of managed codes

Slide 8

Slide 8 of 31 Session 14

Ver 1.0

Querying and Managing Data Using SQL Server 2005

Managed stored procedure:

Is implemented by creating a procedure that refers to an imported assembly

Syntax:

CREATE PROCEDURE <Procedure Name>

AS EXTERNAL NAME <Assembly Identifier>.<Type Name>.<Method Name>,

Let’s see how…

Creating Managed Database Objects (Contd.)

In this topic, you need to explain the concept of creating a managed procedure to the students These managed stored procedures will have an assembly attached to it

Whenever the stored procedure is executed, the code written in the assembly will be executed To explain the concept, you can use the example provided in the Student Guide

Before executing the code, you need to copy the ConvertXML.dll file in the C drive of

the server This file is given in the Datafiles_for_faculty\QMDS2005\Chapter 09 folder

of the TIRM CD

When explaining the syntax of the command, mention that the EXTERNAL NAME clause specifies the database server to use an external assembly as the code for the procedure

Trang 9

¤NIIT Instructor Inputs 14.9

Note

Slide 9

Slide 9 of 31 Session 14

AS EXTERNAL NAME <Assembly Identifier>.<Type Name>.<Method Name>

Let’s see how…

Creating Managed Database Objects (Contd.)

In this topic, you need to explain the concept of managed functions to the students Use

the example provided in the Student Guide to demonstrate the concept

Before executing the code, you need to copy the CalSalAssembly.dll file in the C drive

of the server This file is given in the Datafiles_for_faculty\ QMDS2005\Chapter 09

folder of the TIRM CD

Trang 10

Note

Slide 10

Slide 10 of 31 Session 14

CREATE TRIGGER <TriggerName>

ON <Table or View> <FOR | INSTEAD OF | AFTER>

< INSERT | UPDATE | DELETE >

AS EXTERNAL NAME <Assembly Identifier>.<Type Name>.<Method Name>

Let’s see how…

Creating Managed Database Objects (Contd.)

In this topic, you need to explain the concept of managed triggers to the students Use the example provided in the Student Guide to demonstrate the concept

Before executing the code, you need to copy the ValidateMail.dll file in the C drive of the server This file is given in the Datafiles_for_faculty\ QMDS2005\Chapter 09 folder

of the TIRM CD

Trang 11

¤NIIT Instructor Inputs 14.11

Note

Slide 11

Slide 11 of 31 Session 14

Ver 1.0

Querying and Managing Data Using SQL Server 2005

Managed user-defined type:

Is created by using the CREATE TYPE command Syntax:

CREATE TYPE [ schema_name ] type_name {

FROM base_type [ (precision [ , scale ] ) ] [ NULL | NOT NULL ]

| EXTERNAL NAME assembly_name[.class_name]

}

Let’s see how…

Creating Managed Database Objects (Contd.)

In this topic, you need to explain the concept of managed user-defined types to the students To clarify the concept to the students, you need to run the examples provided in the Student Guide

Before executing the code, you need to copy the ZipCode.dll file in the C drive of the

server This file is given in the Datafiles_for_faculty\ QMDS2005\Chapter 09 folder of the TIRM CD

Trang 12

Slide 12

Slide 12 of 31 Session 14

Ver 1.0

Querying and Managing Data Using SQL Server 2005

Just a minute

When will you use managed code instead of T-SQL?

1 When you need to write queries.

2 When you need to access external resources.

3 When you need to perform an administrative task on the database.

Answer:

2 When you need to access external resources.

Reiterate the concept taught by asking the given question

Slide 13

Slide 13 of 31 Session 14

to store the spouse details in the following format:

Spouse Name: <name of the spouse> ; Spouse Date of Birth :

<date of birth>

To implement this, you have decided to create a managed user-defined data type How will you create this data type?

Demo: Implementing Managed User-Defined Types

At the end of this demo, the students will be able to create a user-defined type using a NET assembly

Trang 13

¤NIIT Instructor Inputs 14.13

Note

Slide 14

Slide 14 of 31 Session 14

3 Create a managed database user-defined data type

4 Create a table that will implement the user-defined data type.

5 Verify the output.

Demo: Implementing Managed User-Defined Types (Contd.)

Before executing the code, you need to copy the SpouseDetails.dll file in the C drive of the server This file is given in the Datafiles_for_faculty\ QMDS2005\Chapter 09 folder

of the TIRM CD

Slide 15

Slide 15 of 31 Session 14

Trang 14

In this topic, you need to explain the concepts of SOA to the students The concept of SOA is new to the students Therefore, you need to clarify the concept

The term service-oriented architecture expresses a perspective of software architecture that defines the use of loosely coupled software services to support the requirements of the business processes and software users

SOA is a collection of services These services communicate with each other The

communication can involve either simple data passing or it could involve two or more services coordinating some activity Some means of connecting services to each other is needed Service-oriented architectures are not a new thing The first SOA for many people

in the past was with the use DCOM or Object Request Brokers (ORBs) based on the CORBA specification

Slide 16

Slide 16 of 31 Session 14

Ver 1.0

Querying and Managing Data Using SQL Server 2005

Web Service is a collection of methods that provide programmable logic used by client applications over the Internet.

SQL Server 2005 provides native XML Web services by using the following open standards:

Hypertext Transfer Protocol (HTTP) Simple Object Access Protocol (SOAP) Web Services Definition Language (WSDL)

Introduction to Web Services

Show the flash presentation to introduce Web services to the students Through this presentation the students will learn about the Web services

Inputs for Flash Presentation

Screen 1

A user sends a request to a Web server to view a website The website further sends request for data to a Web service The web service provides the required data that is used

by the website

Trang 15

¤NIIT Instructor Inputs 14.15

Screen 2

A web services provides a set of functionalities to various clients These clients are

websites that need to show a common data The example that is shown is of stock rates Various websites need to show stock rates and update them frequently A Web service provides update stock details to all the websites

The websites can directly get connected to the Web services created on SQL Server HTTP endpoints are the connecting points through which users can get connected to the Web services

In addition, you can tell the students that Web services implemented in SQL Server contain the stored procedures and functions as Web methods

In addition, you also need to introduce the various technologies used in the creation, searching, and deploying web services You need not explain the details of

implementation of HTTP, SOAP, and WSDL but clarify the concept to the students

„ HTTP: Is a protocol used on the World Wide Web to transfer information The

original purpose of HTTP is to publish and retrieve HTML pages

HTTP is a request/response protocol between clients and servers The originating client, such as a web browser, spider, or other end-user tool, is referred to as the user agent The destination server, which stores or creates resources such as HTML files and images, is called the origin server In between the user agent and origin server may be several intermediaries, such as proxies, gateways, and tunnels

„ SOAP: Is a protocol for exchanging XML-based messages over a computer network,

normally using HTTP SOAP forms the foundation layer of the Web services stack

It provides a basic messaging framework

There are several different types of messaging patterns in SOAP, but by far the most common is the Remote Procedure Call (RPC) pattern, in which one network node (the client) sends a request message to another node (the server), and the server immediately sends a response message to the client

„ WSDL: Is an XML-based service description on how to communicate using the web

service; namely, the protocol bindings and message formats required to interact with the web services listed in its directory The supported operations and messages are described abstractly, and then bound to a concrete network protocol and message format This means that WSDL describes the public interface to the web service

Trang 16

Slide 17

Slide 17 of 31 Session 14

Trang 17

¤NIIT Instructor Inputs 14.17

Slide 19

Slide 19 of 31 Session 14

Identifying the Role of HTTP Endpoints in Native Web Service Architecture

In this topic, you need to explain the concept of HTTP Endpoints to the students To explain the concept of the Web services, you may refer to the examples provided in the Student Guide

SQL Server allows the database developers to create and host native Web services inside SQL Server only

Slide 20

Slide 20 of 31 Session 14

Ver 1.0

Querying and Managing Data Using SQL Server 2005

Identifying the Role of HTTP Endpoints in Native Web Service Architecture (Contd.)

HTTP Endpoint Architecture:

Trang 18

In this topic, you need to explain the execution of a native Web service to the students Explain to the students that if SQL Server is running of Windows 2003 Server, SP1 they need not to have an additional Web Server to host the web service created using SQL Server

The reason why you need not have a Web server is that Windows 2003 server architecture has a separate HTTP listener with it This listener is hosted in http.sys file and listens for any http requests made over the network

Slide 21

Slide 21 of 31 Session 14

Trang 19

¤NIIT Instructor Inputs 14.19

Slide 22

Slide 22 of 31 Session 14

Ver 1.0

Querying and Managing Data Using SQL Server 2005

Involves the following tasks:

1 Creating the required database code to access the data.

2 Creating an HTTP Endpoint using the CREATE ENDPOINT statement.

Creating HTTP Endpoints

In this topic, you need to explain the process of creating an HTTP Endpoint to the

students Tell them that firstly they need to create a required code in the form of one or more stored procedures or functions While creating the endpoint, you will refer to the code written This code will further be converted into a Web method and the data returned

by the code will be converted into XML In addition, the SQL Server will also write the WSDL document for the Web service

Slide 23

Slide 23 of 31 Session 14

[ { WEBMETHOD [ 'namespace' ] 'method_alias' ( NAME = 'database.owner.name'

[ , SCHEMA = { NONE | STANDARD | DEFAULT } ] [ , FORMAT = { ALL_RESULTS | ROWSETS_ONLY } ]) } [ , n ] ]

[ BATCHES = { ENABLED | DISABLED } ] [ , WSDL = { NONE | DEFAULT | 'sp_name' } ]

Let’s see how…

Creating HTTP Endpoints (Contd.)

Ngày đăng: 31/07/2014, 15:20