The SQL Server 2005 database engine provides a platform that allows building and managing data applications.. In addition, SQL Server 2005 combines data analysis, reporting, integration,
Trang 1productive data platform for its business
applications The SQL Server 2005 database engine
provides a platform that allows building and
managing data applications In addition, SQL Server
2005 combines data analysis, reporting, integration,
and notification services to enable organizations to
build and deploy efficient Business Intelligence (BI) solutions
This chapter discusses the importance of a database
server In addition, it provides an overview of SQL
Server 2005, its components, and features The
chapter introduces the Structured Query Language
(SQL) that is used to manipulate data in a database
server Lastly, it discusses the tools provided by
SQL Server 2005 to improve the productivity of the
database developer and manage the server
In this chapter, you will learn to:
Appreciate SQL Server 2005 as a database
server
Identify the SQL Server 2005 tools
Objectives
Trang 3Every organization needs to maintain information related to employees, customers, business partners, or business transactions Organizations build business applications with
a user-friendly interface to store and manipulate this information and to generate reports
In addition, they need a platform that can be used to store and maintain this information in
an efficient way Various database management system (DBMS) and relational database management system (RDBMS), such as SQL Server 2005, Oracle, and Sybase, can be used to maintain this information
SQL Server 2005 is a data engine introduced by Microsoft It lies at the core of the data management solution of an organization It allows secure and efficient storage and
management of data In addition, SQL Server 2005 provides other components and services that support the business intelligence platform to generate reports and facilitate data analysis
As a database developer, it is important for you to identify the role of a database server in
an organization To effectively design and implement database solutions by using SQL Server 2005, it is important for you to identify its components and services In addition, you need to understand the basics of SQL, a language that is used to query and manage data
Organizations have always been storing and managing business data Earlier,
organizations used to store the data on paper With an increase in the usage of computers, organizations began building and using business applications to support the business operations
The business applications accept data as input, process the data based on business
requirements, and provide data or information as output For example, an application that maintains the sales details for an organization, accepts the details of the sales transaction from the users The data is saved and an output message confirming that the data has been saved is displayed to the user
For example, the Human Resource department of an organization uses an application to manage the employee data The users need to add the details of new employees For this, the application provides an interface to enter the employee details These details are validated for accuracy based on business rules For example, a business rule is defined to check that the date of joining of the new employee is less than or equal to the current date
If the data meets the requirements, it is saved in the data store
Introduction to SQL Server 2005
Role of a Database Server
Trang 4Based on the preceding scenario, a business application can have three elements:
The user interface or the presentation element, through which data is input
The application logic or the business rule element, which helps in implementing the operations to be performed on the input data
The data storage or the data management element, which manages the storage and retrieval of data
These elements form the base of the models or architectures used in application
development Depending on the placement of these elements, the application architectures can be categorized as:
Two-Tier Architecture
To address the problems in modifying an application faced in a single-tier application, two-tier architecture was evolved In two-tier architecture, the application is divided into two manageable parts; one part handles the data, while the other provides the user
interface Therefore, this architecture is called two-tier architecture The two parts can be located on a single computer or on separate computers over a network
Trang 5The part that handles the user interface (UI) is called the client tier The part that
implements the application logic and manages the input data based on the business rules is
called the server tier, as shown in the following figure
A Two-Tier Architecture
In this architecture, the maintenance, upgrade, and general administration of data is easier,
as it exists only on the server and not on all the clients
Two-tier architecture is also called client-server architecture Most RDBMSs, such as Microsoft Access, SQL Server, and Oracle, adhere to the client-server architecture RDBMS provides centralized functionality required while supporting many users
Three-Tier Architecture
When implementing complex business solutions in case of a two-tier architecture, the tier
on which the business logic is implemented becomes over loaded As a result, it takes more time to execute Therefore, to provide further flexibility, the two-tier architecture can be split into three tiers In three-tier architecture, the first tier is the client tier, the second or middle tier is called the business tier, and the third tier is called the server tier The server tier contains a database server that manages the data
Trang 6In this architecture, an additional tier called a business tier has been added between the
client tier and the server tier of the two-tier architecture, as shown in the following figure
A Three-Tier Client/Server Architecture
The business tier consists of all the business rules It consists of the application logic that implements rules and checks the data The advantage of a three-tier application is that it allows you to change the business rules without affecting the other two tiers
For instance, in a banking application for loans, the user tier is the front-end used by the customer to specify the loan details The server tier can consist of an RDBMS in which the data is stored The business tier lies between the other two tiers and consists of
business rules, such as the loan limit and the interest rate charged to a customer If there is
a change in the rate of interest, only the middle tier component needs to be modified
N-Tier Architecture
As the business complexities increased, the business tier became larger and
unmanageable This led to the evolution of n-tier architecture, where the business services model was divided into smaller manageable units N-tier architecture is also called as multi-tier architecture
In this architecture, it is possible to keep the UI-centric processing on a computer near the client In addition, you may keep the data-centric processing components on another computer near the database server, so that you gain significant performance benefits
Trang 7The N-tier architecture consists of the following layers:
Client tier
UI-centric processing components
Data-centric processing objects
Database server
The banking application, when further expanded, can depict an example of n-tier
architecture The client tier would deal with the user interface, which would include the user interface controls, such as forms, menus, and toolbars The server tier would
comprise data-handling including saving data to the database server
The business logic would include the rules and guidelines for different types of accounts, interest rates, fixed deposits, ATMs, and overdrafts All these would form the middle tier However, there would be some rules that need to be implemented on the user interface and on the database You can place these rules either on the UI-centric processing
components or data-centric processing components, based on the functionality
Applications that follow multi-tier architecture can be used across various locations For example, in Web applications, the application is stored on the Web server The clients access the application from any location through a browser software The clients make requests and receive responses from the Web server
Trang 8Note
The Web server transfers the request for data to a database server, as shown in the
following figure
Architecture of Web Applications
Depending on the relevance of the business rules, they can be implemented on any of the tiers, such as the Web clients, Web server, or the database server
To provide support to applications where users can send requests simultaneously, the database server needs to be a fast, reliable, and secure SQL Server 2005 is one such comprehensive database platform that provides a fast, reliable, and secure RDBMS It also helps in data analysis with integrated BI tools
A BI application is an application that is used by the top management of an
organization for data analysis to make future decisions BI tools are the tools that help
in creating reports that enable data analysis
Trang 9SQL Server 2005 contains a number of components Each component provides specific services and support to the clients connected to the server
The following figure depicts the components of SQL Server 2005
Apart from providing support for data management, the database engine also provides the following background services:
Service Broker: Provides support for asynchronous communication between clients
and the database server, enabling reliable query processing The client application sends a request to the database server and continues to work The requests sent by the client are queued up at the server, in case the server is not available to process the request immediately Server Broker ensures that the request is processed whenever the server is available
SQL Server 2005 Components
Trang 10 Replication: Allows you to copy and distribute data and database objects from one
database server to another These servers can be located at remote locations to provide fast access to users at widely distributed locations After replicating data, the SQL Server allows you to synchronize different databases to maintain data consistency For example, the database servers for your organization might be located at different locations around the world All the servers store common data To ensure that the data in all the servers is synchronous, you can implement data replication
Full-text search: Allows you to implement fast and intelligent search in large
databases by allowing you to search records containing certain words and phrases You can search for different forms of a specific word, such as ‘produce’, ‘produces’,
or ‘production’ In addition, you can search for synonyms of a given word, such as
‘garment’, ‘cloth’, or ‘fabric’
Notification services: Allows you to generate and send notification messages to the
users or administrators about any event For example, the database administrator should be notified when a database object, such as a table is created or deleted The notification messages can be sent to a variety of devices, such as computers or mobile devices
Integration Services
Integration services allow you to gather and integrate data from various disparate data sources available in an organization You can store the data in a consistent format in a
common database called the data warehouse For example, data in your organization
might be stored in different databases, such as Microsoft Access, FoxPro, or text files You might need to consolidate data from all these sources and save the data in a common set of tables on a database server
Integrating data from different sources that might be stored in different formats and
structures involves various complex operations to resolve data quality issues and convert the data into a common format The integration services provide a set of tasks that help the developer create data integration projects with minimum lines of code Data
integration allows collation of data from all the data sources in a common format to
enable accurate analysis of data
Analysis Services
Analysis services help in data analysis in a BI application These applications are built on
a data warehouse that contains data consolidated from various data sources These
services provide data mining solutions that are built on data integrated in the data
warehouse Data mining solutions allow the users to query and present data in reports that enable business forecasts, such as expected sales or profit estimates in the next financial year
Trang 11Reporting Services
Reporting services provide support to generate comprehensive reports on data in the database engine or in the data warehouse These services provide a set of tools that help in creating and managing different types of reports in different formats Using these services, you can create centralized reports that can be saved to a common server and provide secure and restricted access to these reports
SQL Server Integration with the NET Framework
As against the earlier versions of the SQL Server, Microsoft SQL Server 2005 is
integrated with the NET Framework, as shown in the following figure
Integration of SQL Server 2005 with the NET Framework
The NET Framework is a collection of services and classes and exists as a layer between the NET applications and the underlying operating system SQL Server 2005 uses various services provided by the NET Framework For example, the notification services
component is based on the NET Framework and uses its services to generate and send notification messages
Another advantage of the NET integration is that you can create managed database objects Managed database objects are created by using any NET language and can be embedded within the SQL Server For example, developers can create an object that retrieves data from a Web server and saves it in a database table This provides the
software developer with a flexibility of writing codes in a language the developer is most comfortable with Therefore, as a database developer, it is important for you to understand the NET Framework
Trang 12Note
Just a minute:
Just a minute:
You will learn how to create managed database objects in Chapter 9
Which of the following services of SQL Server 2005 allows you to implement
Trang 13The NET Framework is an environment used to build, deploy, and run business
applications These applications can be built in various programming languages supported
by the NET Framework
The NET Framework is designed to make significant improvements in code reuse, code specialization, resource management, multilanguage development, security, deployment, and administration Therefore, it helps bridge the gap of interoperability between
applications
The NET Framework consists of the following components:
Development tools and languages
Base Class Library
Common Language Runtime (CLR)
Development Tools and Languages
The development tools and languages are used to create the interface for the Windows forms, Web forms, and console applications The development tools include Visual Studio
2005 and Visual C# Developer The languages that can be used are Visual Basic.NET, C#, or J# These components are based on the NET Framework base classes
Base Class Library
The NET Framework consists of a class library that acts as a base for any NET language, such as Visual Basic, NET, and C# This class library is built on the object-oriented nature of the runtime It provides classes that can be used in the code to accomplish a range of common programming tasks, such as string management, data collection,
database connectivity, and file access
Common Language Runtime (CLR)
The CLR is one of the most essential components of the NET Framework It provides an
environment for the application to run The CLR or the runtime provides functionalities, such as exception handling, security, debugging, and versioning support to the
applications
The NET Framework