2013 fall 1 chapter 9: the client/server database environment 楊立偉教授 台灣大學工管系...
TRANSCRIPT
2013 Fall2013 Fall 11
Chapter 9:Chapter 9: The Client/Server The Client/Server
Database EnvironmentDatabase Environment
楊立偉教授台灣大學工管系
註 註 :: 於於 1111 版為版為 Chapter 8Chapter 8
Chapter 9 22
Client/Server SystemsClient/Server Systems
Networked computing model Networked computing model 網路運算模型網路運算模型 Processes distributed between clients and Processes distributed between clients and
servers servers 將要處理的工作散在將要處理的工作散在 ClientClient 與與 ServerServer Client–Workstation (usually a PC) that Client–Workstation (usually a PC) that
requests and uses a servicerequests and uses a service Server–Computer (PC/mini/mainframe) Server–Computer (PC/mini/mainframe)
that provides a servicethat provides a service For DBMS, server is a database serverFor DBMS, server is a database server
Chapter 9 33
Application Logic in C/S Application Logic in C/S SystemsSystems
GUI(Graphic User Interface)
Procedures, functions,programs
DBMS activities
Processing Logic Processing Logic 處理邏輯處理邏輯 I/O processingI/O processing Business rulesBusiness rules Data managementData management
Storage Logic Storage Logic 儲存邏輯儲存邏輯 Data storage/retrievalData storage/retrieval
Presentation Logic Presentation Logic 呈現邏呈現邏輯輯 Input–keyboard/mouseInput–keyboard/mouse Output–monitor/printerOutput–monitor/printer
Chapter 9 44
3 types of Client/Server 3 types of Client/Server ArchitecturesArchitectures
1.File Server Architecture1.File Server Architecture
2.Database Server 2.Database Server
ArchitectureArchitecture
3.Three-tier Architecture3.Three-tier Architecture
Client does extensive processing
Client does little processing
Chapter 9 55
1. File Server Architecture1. File Server Architecture
All processing is done at the PC that requested All processing is done at the PC that requested the data the data
Entire files are transferred from the server to the Entire files are transferred from the server to the client for processing client for processing Ex. 利用網路芳鄰分享 MDB 檔
Problems:Problems: Huge amount of data transfer on the networkHuge amount of data transfer on the network Each client must contain full DBMS Each client must contain full DBMS
Heavy resource demand on clientsHeavy resource demand on clients Client DBMSs must recognize shared locks, integrity checks, Client DBMSs must recognize shared locks, integrity checks,
etc.etc.
FAT CLIENT
Chapter 9 66
Figure 9-2 File server model
FAT FAT CLIENTCLIENT
Chapter 9 77
2. Two-Tier Database Server 2. Two-Tier Database Server ArchitecturesArchitectures
Client is responsible for Client is responsible for I/O processing logic I/O processing logic Some business rules logicSome business rules logic
Server performs all data storage Server performs all data storage and access processing and access processing DBMS is only on serverDBMS is only on server
Chapter 9 88
Advantages of Two-Tier Advantages of Two-Tier ApproachApproach
Clients do not have to be as powerfulClients do not have to be as powerful Greatly reduces data traffic on the Greatly reduces data traffic on the
networknetwork Improved data integrity since it is all Improved data integrity since it is all
processed centrallyprocessed centrally Stored procedures : performs some Stored procedures : performs some
business rules done on server business rules done on server
把較常用或重要的程序預先寫好放在把較常用或重要的程序預先寫好放在 DBMSDBMS 內內
Chapter 9 99
Advantages of Advantages of Stored ProceduresStored Procedures
Compiled SQL statements Compiled SQL statements 編譯後執行編譯後執行快快
Reduced network traffic Reduced network traffic 佔較少的網路佔較少的網路流量流量
Improved security Improved security 安全性較高安全性較高 Improved data integrity Improved data integrity 資料完整性較資料完整性較
高高 Thinner clients Thinner clients 前端運算量較少前端運算量較少
Chapter 9 1010
Figure 9-3 Database server architecture (two-tier)
ThinneThinner r clientsclients
DBMS DBMS only on only on serverserver
Chapter 9 1111
3. Three-Tier Architectures3. Three-Tier Architectures
Thin Client PC just for user interface and a little application
processing. Limited or no data storage (sometimes no hard drive) 例如 : Web Browser
GUI interface (I/O processing)
Browser
Business rules Web Server
Data storage DBMS
ClientClient
Application serverApplication server
Database serverDatabase server
Chapter 9 1212
Figure 9-4a Generic three-tier architecture
Thinnest Thinnest clientsclients
Business rules Business rules on separate on separate serverserver
DBMS only DBMS only on DB serveron DB server
Chapter 9 1313
Advantages of Three-Tier Advantages of Three-Tier ArchitecturesArchitectures
Scalability Scalability ( 在佈署與效能上 ) 具擴充性 Technological flexibility Technological flexibility 具技術彈性 Long-term cost reduction Long-term cost reduction 長期低本降
低 Better match of systems to business Better match of systems to business
needs needs 較符合企業所需 Reduced risk Reduced risk 風險降低
Chapter 9 1414
Application PartitioningApplication Partitioning
Placing portions of the application Placing portions of the application code in different locations (client vs. code in different locations (client vs. server) AFTER it is written server) AFTER it is written 重新切分程重新切分程式執行的位置式執行的位置
AdvantagesAdvantages Improved performanceImproved performance Improved interoperabilityImproved interoperability Balanced workloadsBalanced workloads
Chapter 9 1515
Common Logic Common Logic DistributionsDistributions
Figure 9-5a Two-tier client-server environments
Figure 9-5b n-tier client-server environment
Processing logic could be at client, server, or both
Processing logic will be at application server or Web server
Chapter 9 1616
Role of the Mainframe Role of the Mainframe 大型大型主機主機
Mission-criticalMission-critical legacy systems tend to remain on legacy systems tend to remain on mainframes mainframes
When moving mission critical systems from mainframe When moving mission critical systems from mainframe to distributed client/server systemsto distributed client/server systems
例如例如 : : 銀行核心系統的移轉銀行核心系統的移轉 Determining which code belongs on server vs. clientDetermining which code belongs on server vs. client Identifying potential conflicts with code from other applicationsIdentifying potential conflicts with code from other applications Ensuring sufficient resources exist for anticipated loadEnsuring sufficient resources exist for anticipated load
Rule of thumb Rule of thumb 移轉的經驗法則移轉的經驗法則 Mainframe for centralized data that does not need to be movedMainframe for centralized data that does not need to be moved Client for data requiring frequent user access, complex Client for data requiring frequent user access, complex
graphics, and user interfacegraphics, and user interface
Chapter 9 1717
Benefits of Moving to Benefits of Moving to Client/Server ArchitectureClient/Server Architecture
Staged delivery of functionality speeds Staged delivery of functionality speeds deployment deployment 功能可分階段完成功能可分階段完成
GUI ease application use GUI ease application use 將使用者界面與應用分將使用者界面與應用分離離
Flexibility and scalability facilitates business Flexibility and scalability facilitates business process reengineering process reengineering 更容易擴充 具有彈性更容易擴充 具有彈性
Reduced network traffic Reduced network traffic 只傳處理過的資料只傳處理過的資料 Facilitation of Web-enabled applicationsFacilitation of Web-enabled applications
易於轉為易於轉為 WebWeb 或行動應用或行動應用
Chapter 9 1818
Middleware Middleware 中介軟體中介軟體 Software that allows an application
to interoperate with other software No need for programmer/user to
understand internal processing Accomplished via Application
Program Interface (API)
The “glue”“glue” that holds client/server applications together
Chapter 9 1919
Database MiddlewareDatabase Middleware ODBCODBC–Open Database Connectivity–Open Database Connectivity
Most DB vendors support thisMost DB vendors support this
JDBCJDBC–Java Database Connectivity–Java Database Connectivity可視為可視為 JavaJava 版的版的 ODBCODBC Special Java classes that allow Java Special Java classes that allow Java
applications/applets to connect to databasesapplications/applets to connect to databases
OLE-DBOLE-DB Microsoft enhancement of ODBCMicrosoft enhancement of ODBC
Chapter 9 2020
Using ODBC to Link External Using ODBC to Link External Databases Stored on a Database Databases Stored on a Database
ServerServer Open Database Connectivity (ODBC)Open Database Connectivity (ODBC)
API provides a common language for API provides a common language for application programs to access and process application programs to access and process SQL databases independent of the particular SQL databases independent of the particular RDBMS that is accessedRDBMS that is accessed
Required parameters:Required parameters: ODBC driver ODBC driver Back-end server nameBack-end server name Database nameDatabase name User id and passwordUser id and password
Additional information:Additional information: Data source name (DSN)Data source name (DSN) Windows client computer nameWindows client computer name Client application program’s executable nameClient application program’s executable name
Chapter 9 2121
ODBC Architecture ODBC Architecture (Figure 9-6)(Figure 9-6)
Each DBMS has its own ODBC-compliant driver
Client does not need to know anything about the DBMS
Application Program Interface (API) provides common interface to all DBMSs
Chapter 9
實作 : 實際設定一個 DSN ( 適用 Windows 作業系統 )
控制台→系統管理工具→資料來源 (ODBC) 選「系統資料來源名稱」→選「新增」 選一個適當的驅動程式 (Driver)
Chapter 9
實際設定一個 DSN ( 續 ) 填入所需資料並選取 Access 的 MDB 檔案,確定即可
Chapter 9
使用 ODBC 資料來源 以 MS Access 為例,選檔案→取得外部資料→匯入 選取 ODBC 來源,選取所需要的 DSN 即可
適用所有支援 ODBC資料來源的應用程式
Chapter 9
Web/DB Application Web/DB Application ComponentsComponents
Database server – hosts the DBMSDatabase server – hosts the DBMS e.g. Oracle, MS SQL Server, MS Access, MySQLe.g. Oracle, MS SQL Server, MS Access, MySQL
Web server – receives and responds to browser Web server – receives and responds to browser requests using HTTP protocolrequests using HTTP protocol e.g. Apache, MS IIS (Internet Information Services)e.g. Apache, MS IIS (Internet Information Services)
Application server – software for creating dynamic Application server – software for creating dynamic web sitesweb sites e.g. MS ASP .NET framework, Java EE, PHPe.g. MS ASP .NET framework, Java EE, PHP
Web browser – client program that sends web Web browser – client program that sends web requests and receives web pagesrequests and receives web pages e.g. Internet Explorer, Firefox, Safari, Google Chromee.g. Internet Explorer, Firefox, Safari, Google Chrome
2525
Chapter 9
Static page requests Static page requests .htm or .html requests handled by the Web server.htm or .html requests handled by the Web server
Dynamic page requestsDynamic page requests .jsp, .aspx, and .php requests are routed to the .jsp, .aspx, and .php requests are routed to the
application serverapplication server Server-side processing by JSP servlet, ASP .NET Server-side processing by JSP servlet, ASP .NET
application, or PHPapplication, or PHP Database access via JDBC, ODBC, ADO .NET, or Database access via JDBC, ODBC, ADO .NET, or
other database middlewareother database middleware
2626
Chapter 92727
Figure 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
© 2013 Pearson Education© 2013 Pearson Education