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

Beginning SQL Server 2005 for Developers From Novice to Professional phần 10 pptx

59 441 0

Đ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

Tiêu đề Sql Server 2005 Reporting Services
Trường học University of XYZ
Chuyên ngành Computer Science
Thể loại Bài giảng
Năm xuất bản 2006
Thành phố City Name
Định dạng
Số trang 59
Dung lượng 1,81 MB

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

Nội dung

On the report server, all the items such as reports, report models, and shared data sources are organized using a folder hierarchy.. Report Manager is an ASP.NET web application used as

Trang 1

The Application Layer

At the application layer level, you will find report design tools, configuration tools, and custom applications that use Reporting Services Let’s see how they’re used

Web Browser

The simplest way to access a report server is using a browser On the report server, all the items (such as reports, report models, and shared data sources) are organized using a folder hierarchy The folder hierarchy looks like a file system, but actually all folders and items are stored in SQL Server databases You can navigate through this hierarchy and view reports using a browser The path to a report will be included in the URL used by the browser to display the report For example, one of the reports we will create in the demo section “Building a Report Model” can

be viewed with a browser using this URL: http://localhost/Reports/Pages/Report.aspx?ItemPath=%2fAd+Hoc+Report

Another use for a web browser is web-based management using Report Manager Report Manager is an ASP.NET web application used as a management tool for Reporting Services.Report Tools

A new option in SQL Server 2005 Reporting Services is the ability to create report models and

ad hoc reports A report model hides the complexity of a report Based on a model, a business user can create with limited technical knowledge ad hoc reports You will see them at work in the examples later in the chapter

To create reports, report models, or ad hoc reports, you have several options from Notepad to third-party tools I will not talk about Notepad, but I will mention briefly the other options

Business Intelligence Management Studio

Based on a Visual Studio 2005 shell, Business Intelligence Management Studio is the tool that allows you to create Business Intelligence projects For Reporting Services you have three project templates available: Report Model Project, Report Server Project, and Report Server Project Wizard Using the project templates will actually start the Report Designer and the Model Designer tools, which are design tools for creating the reports and report models.Configuration Tools

For Reporting Services configuration and management, you have several tools at your disposal

We have seen these tools already within the book, but let’s take a moment to see how they fit within Reporting Services

SQL Server Configuration Manager

If you want to configure SQL Server 2005 components services or network libraries, you will use this tool

Trang 2

Surface Area Configuration

This tool will help you to reduce the options of a potential attacker by stopping or disabling

unused components For Reporting Services, you can enable or disable the following features:

• Web services request and HTTP access: If you don’t use a client application that requires

Reporting Services web service, you can disable this feature

• Scheduled events and report delivery: If you only require “on-demand” report delivery,

then you can disable this feature

• Windows Integrated Security: In order to access data sources, you need some credentials If

you disable the Windows Integrated Security feature, you will reduce the probability

that a user’s identity may be used without the user’s consent To access data, you will

have several options for obtaining credentials such as prompted credentials, stored

credentials, or no credentials

Report Manager

I already mentioned this web-based application that allows you to manage a report server

If you don’t want to install any client utilities on your machine, then the best management tool

for you is Report Manager

Reporting Services Configuration Tool

This tool allows you to configure and modify the settings for a reporting services installation

You can configure the virtual directories used by a report server or by the Report Manager

application; you can also configure service accounts, report server databases, or e-mail delivery

If you want to scale-out reporting services, you will need this tool

SQL Server Management Studio

You should already be familiar with this tool that allows the central management for all SQL

Server component servers and it can replace Report Manager

Command Line Tools

In addition to graphical tools, Reporting Services comes with several command line utilities

such as rs (for scripted operations), rsconfig (for configuring the report server connection to

the report server database), rskeymgmt (for encryption key management), and sac (the

command line version of Surface Area Configuration)

Custom Applications

The extensible architecture of all Reporting Services components gives you the possibility to

develop custom applications for the complete reporting life cycle You can build new report

designers, management tools, or just use reports in your applications I want to remind you

that you can use Report Viewer controls, a set of two freely redistributable controls that can

work in local and remote mode In local mode, you can display reports without connecting to

a report server

Trang 3

The Server Layer

At the server layer, we have the report server—a perfect marriage between a Windows service and a web service

Web Service

The web service provides a set of programmatic interfaces that allow communication with the report server It is required for on-demand delivery and for the use of client tools like Report Manager, Report Builder, or SQL Server Management Studio

Windows Service

The Windows service is responsible for scheduling and delivery services, server maintenance, encryption operations, and initialization services It is required for the push delivery method of reports For scheduling operations, the SQL Server Agent Service is required If you need just push delivery reporting, you can run only the Report Server Windows service However, you will have available just a part of the Reporting Services functionality

Programming Interfaces

Applications can use Simple Object Access Protocol (SOAP), URL endpoints, and Windows Management Instrumentation (WMI) to talk to report servers If you are not familiar with web services, they simply allow you to use programmatic functionality (functions, procedures, T-SQL stored procedures, etc.) over the web, by including the call to the functionality in your request

to the web server and the result of the call in the web server’s response The communication protocol used by web services is SOAP SOAP messages have a simple XML form I captured the SOAP message used by Business Intelligence Development Studio to deploy a report You can see that it is not so complicated A report named ContactList is created in a parent folder named Advance Report The existing report, if any, will be overwritten

Trang 4

The importance of SOAP is that anyone can talk SOAP, which is XML To receive SOAP

messages, the Reporting Services web service uses URL endpoints, to which you send your

requests to work with reports SQL Server 2005 Reporting Services comes with two new

endpoints—for report execution and for report management You can use both of them to

build custom tools, though most likely you will be just happy with the existing set of tools

Processors

The only components of Reporting Services that cannot be extended are the Report Processor

and the Scheduling and Delivery Processor The first one is responsible for combining a report

layout with data and rendering a report in a requested format The Scheduling and Delivery

Processor is responsible for delivering reports and supports scheduled operations

Extensions

One of the main qualities of Reporting Services is extensibility You can add custom extensions

for authentication, data processing, report processing, rendering, and delivery

Authentication Extensions

Reporting Services uses a role-based security model in which users and groups are mapped to

roles Roles are just a collection of tasks that can be performed For example, the Report Builder

Role allows a user to build and edit reports with Report Builder You can also define your own

custom roles The default authentication uses Internet Information Services (IIS) to

authenti-cate Windows users and groups You can use a custom authentication extension to get users

from other directory services like Novell Directory Services, for example

Data Processing Extensions

Data processing extensions are used to get data from various sources like SQL Server, Analysis

Services, Oracle, OLE DB, and ODBC data sources

Rendering Extensions

Rendering extensions work with Report Processor to transform the data and the report layout

into a specific format Available are the following rendering extensions: HTML (to generate

HTML using UTF-8 encoding), Excel (to generate reports in a native file format for Excel—Binary

Interchange File Format), CSV (to generate Comma-Separated Value files), Image (to generate

image formats like BMP, GIF, JPEG, TIFF, EMF, WMF), PDF, and XML

Report Processing Extensions

If you need custom report items, you can add new report processing extensions for them

Delivery Extensions

The delivery extensions are used by the Scheduling and Delivery Processor to deliver reports to

locations such as e-mails or file shares You can even send short notices (not the actual report)

to mobile devices like pagers and phones

Trang 5

The Data Layer

At the data layer level, we have two SQL Server databases and a lot of options for data sources.Report Server Databases

SQL Server 2005 Reporting Services uses two SQL Server databases (ReportServer,

ReportServerTempDB) to store the information used by the report server The ReportServer database stores static metadata such as report definitions, data sources, users, roles, subscrip-tions, and schedule definitions The ReportServerTempDB database stores temporary objects such as work tables or session data To store Reporting Services databases, you can use another server and even another version of SQL Server (SQL Server 2000)

Data Sources

The report data sources can come from SQL Server, Analysis Services, Excel, Access, Oracle, flat files or any OLE DB, and ODBC data sources Using data processing extensions, you can add new sources of data

Building Your First Report Using Report Wizard

In this section, we will call the Report Wizard—the perfect tool for a beginner or for an urgent situation The end result will be a simple report containing the list of contacts from the CustomerDetails.Customers table

Try It Out: Using the Report Wizard

1 From the Start menu, select Programs ➤ Microsoft SQL Server 2005 ➤ SQL Server Business

Intelli-gence Development Studio

2 Once Business Intelligence Development Studio has opened, on the File menu, select New ➤ Project.

3 In the Project Types list, click Business Intelligence Projects.

4 In the Templates list, click Report Server Project Wizard.

5 Type ApressFinancial Reports in the name textbox as shown in Figure 14-2 and leave the default

location as it is Click OK to start the Report Wizard

6 On the Welcome page of the wizard, you will see a short description of the wizard You may read it and

then click Next

7 On the Select the Data Source page, make sure that Microsoft SQL Server is selected in the Type

drop-down list

Trang 6

Figure 14-2 Selecting the report template and report name

8 This step defines the source of data for our report We will use the ApressFinancial database from our

local server Use the Edit button to open the Connection Properties dialog box and specify XP-PRO for Server Name and ApressFinancial in Select or Enter a Database Name as shown in the following screenshot

Trang 7

An alternative is to remain in the Data Source page and type Data source= XP-PRO; Initial Catalog= ApressFinancial in the Connection String textbox as you see in Figure 14-3 Click Next.

Tip Remember to change the Data source to the SQL Server instance you are connecting to, such as (local)

9 In the Design the Query page, shown in Figure 14-4, you can use the Query Designer to build your query

This example is very simple, so just use the Query string text box to enter the following SELECT statement and click Next:

SELECT CustomerFirstName, CustomerLastName FROM CustomerDetails.Customers

10 The next step is to select a report type Select Tabular and click Next.

11 To make the report really simple, I will not use any kind of grouping In the Design the Table page, shown

in Figure 14-5, you can select fields by which to group or fields to display in the Report Details section Select the CustomerFirstName and CustomerLastName fields and click the Details button to add them to the details section Click Next

Trang 8

Figure 14-4 Design the Query window

Trang 9

12 The Choose the Table Style page allows you to apply a style to the report by selecting a style template

I prefer the style template named Corporate Select one template and click Next

13 The next page, Choose the Deployment Location, allows you to configure the report server and the

folder to which the report will be published The Report Wizard will not publish the report You can do that yourself later on

14 The last step gives you a last chance to verify the information entered You have the option to rename

the report, but for this demo leave the default name—Report1 Select the Preview Report check box to preview the report as soon as the wizard finishes Click Finish

Congratulations! You just did your first report If you did everything just right, you should see the preview of your report, which should resemble Figure 14-6

You can see the two columns selected in step 11, the tabular format of data because of the choice you selected in step 10, and of course, the great name Report1 that you can change if you choose to

In the next section, I will tell you about various report items

Building a Report from Scratch

In this section, you will learn to build a report without the help of Report Wizard That means that you will have to define a data source and build a design for your report Once the report is built, I will show you how to add some interactivity by using parameters Before we do the actual demo, let’s take a closer look at some of the elements we can use

Trang 10

Data-Related Elements

The utility of a report is given mainly by its data In order to have data in a report, you have to

define at least a data source and a dataset The data view of the graphical designer interface

allows you to create datasets and data sources

Data Source

A data source represents the necessary information to get to the source of data Such

informa-tion may include a server name, a database name, and user credentials The informainforma-tion

included depends on the source of data, for example, if you use a text file, you will specify the

path to the text file and not a server name or a database name A report can use multiple data

sources There are two types of data sources: shared (can be used by multiple reports) or report

specific (used by a particular report) Another difference between shared and report-specific

data sources is their storage location A shared data source is stored in a separate file on the

report server, while the report-specific data source is stored in the report definition

Dataset

Once we have defined the source of data, we will create a dataset using a query You can imagine

a dataset as a set of rows with data I would mention that a report can also have multiple datasets

Fields

Every row of a dataset has one or more fields that typically refer to columns returned by the

query that populated the dataset You can find all fields of a dataset in the Fields window Using

the drag-and-drop method, you can include any field in your report

Custom fields

Besides the existing fields of a dataset, you can create new ones using several methods You can

create calculated fields based on existing fields, or you can use aggregate functions such as Sum,

Avg, and Count

Report Items

There are two types of report items: data regions and independent items

Data Regions

Data regions display data from datasets, with each data region being associated to one dataset

You can use the following types of data regions:

• Table: A table is a data region that uses static columns and rows to display data.

• Matrix: A matrix (or crosstab) is a more complex data region having columns and rows

that can contain other columns or rows

Trang 11

• List: A list allows you to display data in a free-form way It basically repeats each row (or

group) in a dataset

• Chart: A chart data region displays the data in a graphical form, allowing you to use

charts like bar charts, pie charts, and other types of charts

• Line: A line is a graphical element that can be placed anywhere in your report You can

apply different styles to it, you can make it horizontal, vertical, diagonal, etc

• Image: An image control allows you to display images from a file, URL, or database field.

• Rectangle: A rectangle is a graphical element that can be used to group other items, and

as the name says its shape is rectangular

• Subreport: A subreport is an item that references the body of another report.

Reports Structure

A report can contain different sections such as report header and footer (that appear on the first and the last pages, respectively), page headers and page footers (that appear on all pages), and table headers and footers (displayed at the beginning and the end of a table) If you have groups, you can use group headers and group footers

That should be enough to give you an overview on what you need to create a report Let’s start the demo

Try It Out: Creating a Report Structure

I will use a new simple table for this report Open SQL Server Management Studio and run the following script:USE ApressFinancial

GOCREATE TABLE CustomerDetails.Title(CustomerTitleId int primary key,TitleDescription varchar(16))GO

INSERT INTO CustomerDetails.Title VALUES (1,'Mr')INSERT INTO CustomerDetails.Title VALUES (2,'Ms')INSERT INTO CustomerDetails.Title VALUES (3,'Dr')

1 Open Business Intelligence Development Studio and on the File menu, select New ➤ New Project.

2 Click Business Intelligence Projects in the Project Types list Click the Report Server Project template.

3 In the Name textbox, type Advanced Report and then click OK to create the project.

Trang 12

4 Make sure that Solution Explorer window is visible To display it, from the View menu click Solution Explorer.

5 In Solution Explorer, right-click Reports, and select Add ➤ New Item.

6 In Add New Item, click Report.

7 In Name textbox, type ContactList.rdl and then click Add The new report will open in Data view.

In this section, we will create a data source for the report and two datasets

8 In the Data view, expand the Dataset drop-down list, and select New Dataset to open the Data Source

dialog box

9 In the Name textbox, type ApressFinancial In the Type drop-down menu, select Microsoft SQL Server.

10 In the Connection string textbox, type the following:

Data source=XP-PRO; Initial Catalog=ApressFinancial

Trang 13

11 Click OK to add the ApressFinancial dataset.

12 Type the following query into the SQL pane that opened:

SELECT C.CustomerFirstName, C.CustomerLastName, T.TitleDescriptionFROM CustomerDetails.Customers C

JOIN CustomerDetails.Title T

ON C.CustomerTitleId = T.CustomerTitleId

13 Click the Run (!) button on the Query Designer toolbar to see the results of the query.

14 To create a second dataset, expand the Dataset drop-down list, and select New Dataset.

15 In the Dataset dialog box, type TitleList in the Name textbox, leave ApressFinancial as the data source,

make sure that in the Command type drop-down list Text is selected, and in the Query string textbox type the following:

Trang 14

SELECT TitleDescription FROM CustomerDetails.Title

16 Click OK to add the TitleList dataset Optionally, you can click the Run (!) button on the Query Designer

toolbar to see the results of the query

In this section, we will add a table data region to the report layout

17 Click the Layout tab to display the Layout view.

18 If the Toolbox window is not displayed, from the View menu click Toolbox It may be just a small tab on

the top left of your design area so it may not be obvious

19 In the Toolbox window, click the Table control and then click the design surface A table with three

columns is generated

20 In the Datasets explorer, probably on the left of the design pane, expand the ApressFinancial dataset to

see the fields

21 Drag the CustomerFirstName field to the detail row (the middle row) of the first column.

22 Drag the CustomerLastName field to the detail row (the middle row) of the second column.

23 Drag the TitleDescription field to the detail row (the middle row) of the third column Your columns

should now resemble those shown in Figure 14-7

Trang 15

Figure 14-7 The design surface

24 Use the File menu and click Save All Click the Preview tab to see the report.

Try It Out: Enhancing the Report

In this section, we will change the design by adding a new column, and we will add some interactivity to our report using a parameter

1 Click the Layout tab to display the Layout view.

2 Double-click the first column of the first row in the table that displays the text Customer First Name

Delete the word Customer

3 Repeat the step for the second column.

Trang 16

4 Delete the Description word from the third column using the same method.

5 Click the table to display the column and row handles Right-click the handle of the third column (Title)

and select Insert Column To the Right, as shown in Figure 14-8

6 Double-click the detail row for the new column (the fourth) Enter the following expression that will calculate

Trang 17

Try It Out: Deploying the Report (Optional)

In this section, we will deploy the report to the local report server and use Report Manager to view the report

1 In the Solution Explorer, right-click Advanced Report solution, and select Properties.

2 In the TargetServerURL textbox, type http://localhost/ReportServer and click OK.

3 The Report Services service has to be running This will only be started manually unless you have changed

the default within your Services From the Control Panel, select Administrative Tools, then select Services Find SQL Server Reporting Services, right-click, and click Start as seen in the following illustration:

4 In the Solution Explorer, right-click Advanced Report solution, and select Deploy.

5 Open Microsoft Internet Explorer and in the address bar, type the Report Manager URL: http://localhost/ Reports/ This will then redirect you to the reports pages (see Figure 14-9).

Trang 18

Figure 14-9 The Report Manager

6 Click the Advanced Report folder Click the Contact List report (see Figure 14-10)

And that will conclude this demonstration

Trang 19

This brings us to the end of Beginning SQL Server 2005 Programming, demonstrating how to

report on the data within the example we have been building up throughout the book There has been an overview of how reporting services works and is architected, and we have seen an overview of building a simple report and previewing the results The next move for you would

be to read Pro SQL Server 2005 (Apress, 2005; ISBN 1590594770) and also Pro SQL Server 2005 Assemblies (Apress, 2005; ISBN 1590595661).

Trang 20

■ ■ ■

A P P E N D I X

Glossary of Terms

The aim of this glossary is to provide you with a quick and easy-to-use reference to many of

the terms that you will come across in this book

When beginning to study a new area of interest (especially in specialized areas), whether it

be computing or not, it is very easy for a book, or any discussion for that matter, to get bogged

down in new terminology, making it difficult for a new reader to advance in their knowledge of

the subject at hand Essentially, that’s where this glossary comes in Hopefully, this glossary

will help you come to grips with SQL Server, and you may also find this to be a practical

refer-ence guide for use in meetings, or indeed any other situation while you are starting out with

SQL Server So, without further ado, let’s begin

A

alias

A substituted name for a database, table, column, or other database object If you have, for

example, a table or a column with a long name, or if you are joining two tables together and

both have a column name that is the same, or if the name of a column doesn’t lend itself to

describing the contents of the data that it holds well enough for output displayed, then you

could use an alias on the column name In this way, you can assign a more descriptive name

to the column, via the alias, thereby making it easier to see just what the data in the column

actually represents The alias on the column name would typically be used within SELECT

statements or WHERE clauses of SQL commands

You can also alias table names to make it easier when building queries joining two tables, so

that the alias is used in defining the join conditions, rather than a long table name

ANSI

Acronym for American National Standards Institute, a body of representatives from industry

and business based in America that defines standards in many areas, one of which deals

with databases

Trang 21

When logging in to SQL Server, whether using Windows authentication or SQL Server authentication, this refers to the process of verifying that the submitted user ID is valid for

a given instance of SQL Server, and then allocating permissions to that user based upon his

or her user profile

B

backup device

Describes a hardware device such as a tape drive used to back up a SQL Server database

If a tape drive is used, then the tape drive must be attached directly to the computer that the SQL Server database resides on, and cannot be a tape drive found on a remote computer elsewhere on the network This can also refer to a file on the same computer, or another server if required

batch

A set of T-SQL statements forming one group, or batch, of actions In Query Editor, you define the end of a batch by employing a GO statement, or another statement set via options within Query Editor A batch allows you to put together a set of work that either has to be a batch because of the way SQL Server works, or you wish to “batch” together a set of work as one single unit Finally, certain T-SQL commands must be placed in a batch on their own with no other T-SQL commands These are statements like CREATE TABLE

BEGIN TRAN[SACTION]

This statement is used to denote the start of a transaction, in which modifications will be made to data that can either be placed in to the database using a COMMIT TRAN[SACTION], or rejected using a ROLLBACK TRAN[SACTION]

An index on a table (or view) that defines the physical order in which the data will be stored

on the table (or view)

COMMIT TRAN[SACTION]

Used to inform SQL Server that any data modifications performed within a transaction, by using the BEGIN TRAN[SACTION] statement , are to be accepted as being valid and are to be committed to the database (that is, permanently written to the database)

Trang 22

A constraint can be a check placed against a table column to ensure that the data entered is

valid or of a default value; a foreign key constraint identifies the relationship between two

tables, while a primary key constraint identifies the column(s) that make a unique primary

key on a table

control-of-flow language

The T-SQL structures contained within a stored procedure, trigger, or batch of queries

that determines the flow of execution of T-SQL statements Contains commands such as

BEGIN END and IF ELSE, among others

D

data integrity

Ensuring that all the data stored within your database is valid, and that there are no

incon-sistencies between rows or tables of any information Maintaining data integrity is paramount to

the success of your database solution, and can be achieved through the use of constraints,

keys, and triggers

database

A repository of objects holding information that makes up a single unit of information

A database will hold not only rows and columns of information within a table, but also

objects that let you work with that data, such as stored procedures, views, etc

database diagram

A graphical representation generated by SQL Server that displays all or a subset of the tables

and relationships within a SQL Server database A default database diagram can be

specifi-cally generated by a developer, and is displayed within SQL Server Management Studio

However, there can be as many diagrams as desired containing any tables within the database

deadlock

Occurs when there is a cyclic dependency between two or more threads for some set of

resources This can be seen when there are two transactions trying to complete an update

simultaneously For example, when transaction 1 has updated one table (TableA), and is

trying to update another table (TableB), the second transaction has updated TableB, and is

waiting to update TableA After a period of time, SQL Server will choose a deadlock victim,

which is the update to be canceled and rolled back

Note Deadlock is a condition that can occur on any system with multiple threads, not just on a relational

database management system

Trang 23

default database

When a user is created in SQL Server, a default database is automatically assigned to him or her (this is master by default) This can be changed to any other database within the server When no specific database is defined in a connection made by programs written in languages such as C#, Java, etc., the default database assignment is used to denote which database will

be connected to

default instance

An instance of SQL Server installed on a server with no instance name specified The name

of the instance is thus just the computer name Multiple instances of SQL Server can be installed on the same computer; however, only one can be the default instance The other instances are referred to as named instances and have the form

computername\instancename

delimiter

Characters that denote the start and end of object names Delimiter characters are either double quotation marks or square brackets

differential database backup

When a backup of a database is made, only the changes made to the database since the last full database backup are reflected

F

foreign key (FK)

A column or set of columns that match the definition of a primary key or a unique key from another table A foreign key is used to establish relationships between two tables through the correspondence between the foreign key and the primary key

foreign table

If a table has a foreign key, then the table is known as a foreign table, and the use of this term

is most common when discussing relationships between tables

When you wish to give a user or, indeed, a group of users defined within a role, permissions

to access or work with a database object, then you need to grant permission to them to perform the desired task using the GRANT statement

Trang 24

identity column

A specialized column within a table that has its value automatically inserted by SQL Server

each time a new record is inserted This value cannot be altered The value is unique for the

table and is based upon a starting point and an increment for each insertion

index

By creating an index on a table, you can potentially speed up access and data retrieval from

a table or a view An index consists of one or more columns from a table

instance

An installation of SQL Server on a local or remote computer It is possible to have multiple

instances of SQL Server installed and running simultaneously on the same computer, with

some or all instances registered within SQL Server Management Studio

ISO

ISO stands for the International Organization for Standardization This is one of the two

international standards bodies responsible for developing international data communication

standards The other organization is the International Electrotechnical Commission (IEC)

ISO and IEC are responsible for the 92 standard for SQL If a database is defined as

SQL-92 compliant, this means it meets the requirements described in this standard, which is set

by these two organizations

J

JOIN condition

A T-SQL clause or a condition forms a relationship that is used to relate two tables and make

them appear as one There are different types of joins such as INNER, OUTER, and CROSS

K

key

A single column or combination of columns that defines a single row as unique, such as a

primary key or unique key, or defines a relationship between two tables, such as a foreign key

L

local server

An example of local server is the type of server used throughout this book, where the instance of

SQL Server is running on the same computer as the application

Trang 25

local variable

Within a stored procedure or query, when wishing to store values without wanting to place them within a table, you can place them within a user-defined, locally scoped variable using the DECLARE statement You can then assign a value using a SELECT or SET statement As soon

as the batch of work is complete, the local variable is no longer valid, and the values within will have been destroyed

lock

When updating data, a lock is placed on the data stopping any other connection from being able to modify the data that has been locked, until such time as the process is finished and releases the lock A lock is released at the end of a transaction when its work has been processed Locks should be held for as short a time as possible to avoid a deadlock situation There are different levels of locking from row-level locking to full table-level locking

master database

This is the most important database within SQL Server, as it serves as the database that controls logins, environment settings, and system error messages This database should not be altered manually Using commands or system stored procedures within SQL Server will alter the database, but it is only through these system stored procedures, such as sp_configure, that the master database should be altered This database also holds the location of the files

of all other databases

Trang 26

nonclustered index

An index where the columns listed within the index do not define the physical order of the

data in the table the index is defined on (as opposed to a clustered index)

NULL

A NULL value indicates that no data is stored in a column This is a special entry within a

column, as it can be placed in any data type and yet means nothing If you find this value

within a column, you cannot compare it through a comparison with any other value, other

than another NULL, which is a special comparison In other words, it is not less than or greater

than any other value, or equal to any other value, even another NULL value

nullability

Expresses whether or not a column or a parameter can accept NULL values

O

object

An object is any component contained within a database As such, an object can range from

a database table right through to a stored procedure

one-to-many relationship

Similar to a many-to-one relationship, wherein there is one row in the master table being

related to many rows in a child table However, the difference here is it is the master table

that is driving the relationship An example is a table for orders (one) with a table of order

details (many)

one-to-one relationship

This relationship is rarely found, and exists when every record in one table has a relationship

with a single record in another table, and vice versa This could be when a single row in a

table becomes split in two where data in one table is referenced frequently, and data in the

other table is not so frequently referenced This will then speed up data retrieval on the

frequently referenced table

P

precision

The number of digits found in a noninteger number both to the left and to the right of the

decimal point

Trang 27

primary key (PK)

A single column or a set of columns from a single table that can uniquely identify a row of data within that table or view No two rows can have the same value within a primary key, and no column defined for the primary key can contain a NULL value

Q

query

A single or set of T-SQL statements that deals with any aspect of data manipulation or retrieval Queries can be run once, or run many times, and quite often are stored within stored procedures

R

referential integrity (RI)

A state wherein all the relationships between tables are valid, commonly achieved using constraints and keys, to ensure that data integrity, hence referential integrity, remains valid Preserving referential integrity will ensure that all data within the database is in alignment

ROLLBACK TRAN[SACTION]

If, when working within a transaction, you decide that you no longer wish for any data fications within the transaction to be committed to SQL Server, then you would issue a ROLLBACK TRAN[SACTION] statement that will restore the original values to all of the columns and all the rows that have been modified in the most recent transaction

modi-row

A single, “horizontal” set of values that have come from one or more tables through a query,

or a single “horizontal” set of values from all columns within a table This can also be called

Used to define the value of a variable rather than using SELECT

SQL (Structured Query Language) query

An action that will either manipulate or retrieve data from objects within SQL Server or any other database that supports SQL, for example, Oracle or Sybase

Trang 28

SQL Server authentication

A method for validating login attempts to SQL Server using a user ID and password that are

defined with SQL Server

stored procedure

A set of T-SQL statements grouped together and stored as a compiled object within SQL

Server, associated to a particular table Can contain control of flow, error statements, etc

subquery

A SELECT statement that is used to aid data selection, by being nested within another SQL Query

T

table

A database object that contains rows and columns of data Each column will have a predefined

data type and may also have constraints, indexes, and keys associated with it

table scan

Occurs when SQL Server scans every row within a table while performing a SQL command,

rather than using an index It does this because it is faster to scan the table rather than look

at an index, then retrieve the data from the table, then move back to get the next index item,

etc., and tends to occur when there are no indexes that return a low percentage of the data

To clarify, an ideal index should return a low number of rows; otherwise, a table scan is

highly likely to occur

tempdb

Transient database that will hold any temporary tables, indexes, and any temporary storage

needed by a query, stored procedure, or any system process

temporary table

A table placed in the tempdb, which is then lost at the end of the session that built it It could

also be a table defined with a single hash, #, or double hash, ##

Transact-SQL (T-SQL)

A language extension to the SQL-92 defined standards for a database to allow administrating

data and objects within SQL Server

transaction

A logical unit of work, such that if it contains any data modifications, these modifications

can be committed or rolled back depending upon a decision that can be made at any time

within the transaction Related to BEGIN TRAN[SACTION], COMMIT TRAN[SACTION], and ROLLBACK

TRAN[SACTION]

Trang 29

An index that defines that no two rows within a table are the same.

user-defined data type

A data type based upon a SQL Server data type created by the user or built using NET code, which will not be based on a SQL Server base data type

user-defined function (UDF)

A function that can be created by a user to perform frequently used, or business-related, logic User-defined functions are different from stored procedures because they are like code snippets rather than full-blown procedures and can form a column in a result set These user-defined functions can be written in T-SQL or NET code

V

variables

Holders of values used in queries, stored procedures, etc.; although they can hold tion from a column of data from a table, they are not actually part of any table Variables are defined by using the DECLARE command and are prefixed with the @ sign Values are placed into variables using the SET or the SELECT statement

informa-view

A database object that can be used as a security measure when dealing with data that is sensitive, or to make data schemas more friendly and usable for user-defined data queries Acts in a similar fashion to a table, and although called a view, data can be updated and deleted providing specific conditions are met

Ngày đăng: 14/08/2014, 10:22

TỪ KHÓA LIÊN QUAN