The Client/Server Database Environment

Download Report

Transcript The Client/Server Database Environment

CHAPTER 8:
DATABASE APPLICATION DEVELOPMENT
Modern Database Management
12th Edition
Global Edition
Jeff Hoffer, Ramesh Venkataraman,
Heikki Topi
授課老師:楊立偉教授,台灣大學工管系
CLIENT/SERVER ARCHITECTURES
Networked computing model網路運算模型
 Processes distributed between clients and
servers 將要處理的工作散在Client與Server
 Client–Workstation (PC, smartphone, tablet)
that requests and uses a service
 Server– Powerful computer
(PC/mini/mainframe) that provides a service
 For DBMS, server is a database server
 For the Internet, server is a web server

Chapter 8
8-2
APPLICATION LOGIC IN C/S SYSTEMS
Presentation Logic 呈現邏輯


Input–keyboard/mouse
Output–monitor/printer
GUI Interface
(Graphic User Interface)
Processing Logic 處理邏輯



I/O processing
Business rules
Data management
Procedures, functions,
programs
Storage Logic 儲存邏輯

Data storage/retrieval
Chapter 8
DBMS activities
8-3
APPLICATION PARTITIONING
 Placing
portions of the application code in
different locations (client vs. server) after
it is written 重新切分程式執行的位置
 Advantages
 Improved
performance
 Improved interoperability
 Balanced workloads
Chapter 8
8-4
FIGURE 8-2 COMMON LOGIC DISTRIBUTIONS
a) Two-tier client-server environments
Processing logic could be at client (fat client), server (thin client),
or both (distributed environment).
Chapter 8
8-5
FIGURE 8-2 COMMON LOGIC DISTRIBUTIONS
b) Three-tier and n-tier client-server environments
Processing logic
will be at
application
server or Web
server.
Chapter 8
8-6
3 TYPES OF CLIENT/SERVER ARCHITECTURES
Client does
extensive processing

1.File Server Architecture

2.Database Server Architecture

3.Three-tier Architecture
Client does little
processing
Chapter 8
8-7
1. FILE SERVER ARCHITECTURE



All processing is done at the PC that requested the data
Entire files are transferred from the server to the client
for processing Ex. 利用網路芳鄰分享Acces檔
Problems:


Huge amount of data transfer on the network
Each client must contain full DBMS
Heavy resource demand on clients
 Client DBMSs must recognize shared locks, integrity checks, etc.

Chapter 8
8-8
FAT CLIENT
Chapter 8
8-9
2. TWO-TIER DATABASE SERVER
ARCHITECTURES
 Client
workstation is responsible for
 Presentation
logic
 Data processing logic
 Business rules logic
 Server
performs all data storage, access,
and processing
 Typically
called a database server
 DBMS is only on server
Chapter 8
8-10
Figure 8-3 Database server architecture (two-tier architecture)
Front-end programs
Back-end functions
Chapter 8
8-11
ADVANTAGES OF TWO-TIER APPROACH
Clients do not have to be as powerful
 Greatly reduces data traffic on the network
 Improved data integrity since it is all processed
centrally
 Stored procedures : performs some business
rules done on server
把較常用或重要的程序預先寫好放在DBMS內

Chapter 8
8-12
ADVANTAGES AND DISADVANTAGES OF
STORED PROCEDURES

Advantages
 Performance
improves for compiled SQL statements
改進效能
 Reduced network traffic佔較少的網路流量
 Improved security 安全性較高
 Improved data integrity資料完整性較高
 Thinner clients前端運算量較少

Disadvantages
 Proprietary,
so algorithms are not portable, and
programming takes more time 專屬不相通
Chapter 8
8-13
THREE-TIER ARCHITECTURES
Client
GUI interface
(I/O processing)
Browser,
Mobile App
Application server
Business rules
Web Server
Database server
Data storage
DBMS
Thin Client

Chapter 8
PC just for user interface and a little application
processing. Limited or no data storage (sometimes no
hard drive) 例如: Web Browser
8-14
Figure 8-6a Generic three-tier architecture
Thin
clients
Business rules
on application
server
Chapter 8
Business rules on
separate
DBMSserver
only on
DB server
8-15
ADVANTAGES OF THREE-TIER ARCHITECTURES
Scalability (在佈署與效能上) 具擴充性
 Technological flexibility 具技術彈性
 Long-term cost reduction 長期低本降低
 Better match of systems to business needs 較
符合企業所需
 Reduced risk 風險降低

Chapter 8
8-16
ROLE OF THE MAINFRAME 大型主機


Mission-critical legacy systems tend to remain on mainframes
When moving mission critical systems from mainframe to
distributed client/server systems
例如: 銀行核心系統的移轉



Determining which code belongs on server vs. client
Identifying potential conflicts with code from other applications
Ensuring sufficient resources exist for anticipated load
Chapter 8
8-17
BENEFITS OF MOVING TO
CLIENT/SERVER ARCHITECTURE





Staged delivery of functionality speeds deployment
功能可分階段完成
GUI ease application use 將使用者界面與應用分離
Flexibility and scalability facilitates business process
reengineering 更容易擴充 具有彈性
Reduced network traffic 只傳處理過的資料
Facilitation of Web-enabled applications
易於轉為Web或行動應用
Chapter 8
8-18
MIDDLEWARE 中介軟體 / API 應用程式介面
Middleware – software that allows an
application to interoperate with other software
without requiring user to understand and code
low-level operations
 Application Program Interface (API) – routines
that an application uses to direct the
performance of procedures by the computer’s
operating system

 Common
database APIs – ODBC, ADO .NET, JDBC
The “glue” that holds client/server applications together
Chapter 8
8-19

ODBC–Open Database Connectivity
 Most

DB vendors support this
JDBC–Java Database Connectivity
可視為Java版的ODBC
 Special
Java classes that allow Java
applications/applets to connect to databases

ADO.NET
 Microsoft
Chapter 8
data access services 微軟的資料庫存取元件
8-20
USING ODBC TO LINK EXTERNAL DATABASES
STORED ON A DATABASE SERVER

Open Database Connectivity (ODBC)


Required parameters:





API provides a common language for application
programs to access and process SQL databases
independent of the particular RDBMS that is accessed
ODBC driver
Back-end server name
Database name
User id and password
Additional information:



Data source name (DSN)
Windows client computer name
Client application program’s executable name
Chapter 8
8-21
ODBC ARCHITECTURE
Client does not need to
know anything about the
DBMS
Application Program
Interface (API) provides
common interface to all
DBMSs
Each DBMS has its own ODBC-compliant driver
Chapter 8
8-22
實作: 實際設定一個DSN

(適用Windows作業系統)



控制台→系統管理工具→資料來源(ODBC)
選「系統資料來源名稱」→選「新增」
選一個適當的驅動程式(Driver)
Chapter 8
8-23
實際設定一個DSN (續)

填入所需資料並選取Access的檔案,確定即可
Chapter 8
8-24
使用ODBC資料來源


以MS Access為例,選檔案→取得外部資料→匯入
選取ODBC來源,選取所需要的DSN即可
適用所有支援ODBC
資料來源的應用程式
Chapter 8
8-25
STEPS FOR USING DATABASES VIA MIDDLEWARE
APIS 在程式中存取資料庫的方式
1.
2.
3.
4.
5.
6.
Identify and register a database driver.
Open a connection to a database.
Execute a query against the database.
Process the results of the query.
Repeat steps 3–4 as necessary.
Close the connection to the database.
Chapter 8
8-26
Chapter 8
8-27
THIN CLIENT
 An
application where the client
accessing the application primarily
provides the user interfaces and some
application processing, usually with no
or limited local data storage.
 Usually, thin client application is a Web
browser and the 3-tier architecture
involves a Web application.
Chapter 8
8-28
Figure 8-7 A database-enabled intranet/Internet environment
Chapter 8
8-29
WEB APPLICATION COMPONENTS

Database server – hosts the DBMS


Web server – receives and responds to browser
requests using HTTP protocol


e.g. Apache, Internet Information Services (IIS)
Application server – software building blocks for
creating dynamic web sites


e.g. Oracle, SQL Server, Informix, MS Access, MySql
e.g. MS ASP .NET framework, Java EE, ColdFusion, PHP
Web browser – client program that sends web
requests and receives web pages

e.g. Internet Explorer, Firefox, Safari, Google Chrome
Chapter 8
8-30
PROCESSING IN 3-TIER APPLICATIONS

Static page requests
 .htm

or .html requests handled by the Web server
Dynamic page requests
 .jsp,
.aspx, and .php requests are routed to the
application server
 Server-side processing by JSP servlet (Java), ASP
.NET application (C# or VB), ColdFusion, or PHP
 Database access via JDBC, ADO .NET, or other
database middleware
Chapter 8
8-31
Figure 8-9 Information flow in a three-tier architecture
No server side processing, just a page return
Server side processing, including database access
…also *.aspx or *.php
Chapter 8
8-32
Figure 8-12 A registration page written in ASP .NET
b) Form for the ASP .NET application
Chapter 8
8-33
Figure 8-12 A registration page written in ASP .NET
a) Sample ASP .NET code for user registration
A
DetailsView
is a type of
Web control
Web controls can be databound to data
sources, including SqlDataSource.
Chapter 8
8-34
CLOUD COMPUTING
A model for creating ubiquitous, convenient, ondemand access to network services
 Characteristics: on-demand, broad network
access, resource pooling, rapid elasticity,
measured service
 Types of cloud computing: 由下至上通常分成三層

(SaaS) 應用服務層
 Platform-as-a-service (PaaS) 作業系統層 (通常DB在這)
 Infrastructure-as-a-service (IaaS) 虛擬主機層
 Software-as-a-service
Chapter 8
8-35
Figure 8-18 Web services deployment
Source: Based on Newcomer (2002).
透過Web services可實現Service Oriented Architecture (SOA)
Chapter 8
8-36
XML AND WEB SERVICES

Web Services – a set of emerging XML-based standards that
define protocols for automatic communication between
software programs over the Web

Universal Description, Discovery, and Integration
(UDDI) – standard for creating a distributed registry of Web
services

Web Services Description Language (WSDL) – XMLbased grammar for describing a Web Service and specifying its
public interface

Simple Object Access Protocol (SOAP) – XML-based
communication protocol for sending messages between
applications over the Internet
Chapter 8
8-37
Figure 8-17 Web Services protocol stack
Chapter 8
8-38
SOAP request sent from customer to supplier
SOAP response sent from supplier to customer
Chapter 8
8-39