Chapter 9 The ClientServer Database Environment 11Chapter 8
Chapter 9: The Client/Server Database Environment 註 : 於 11版為Chapter 8 楊立偉教授 台灣大學 管系 2013 Fall 1
Client/Server Systems n n n Networked computing model 網路運算模型 Processes distributed between clients and servers 將要處理的 作散在Client與Server Client–Workstation (usually a PC) that requests and uses a service Server–Computer (PC/mini/mainframe) that provides a service For DBMS, server is a database server Chapter 9 2
Application Logic in C/S Systems Presentation Logic 呈現邏輯 n n Input–keyboard/mouse Output–monitor/printer GUI (Graphic User Interface) Processing Logic 處理邏輯 n n n I/O processing Business rules Data management Storage Logic 儲存邏輯 n Data storage/retrieval Chapter 9 Procedures, functions, programs DBMS activities 3
3 types of Client/Server Architectures Client does extensive processing n 1. File Server Architecture n 2. Database Server Architecture n 3. Three-tier Architecture Client does little processing Chapter 9 4
1. File Server Architecture n n n All processing is done at the PC that requested the data FAT CLIENT Entire files are transferred from the server to the client for processing Ex. 利用網路芳鄰分享MDB檔 Problems: n n Huge amount of data transfer on the network Each client must contain full DBMS n n Chapter 9 Heavy resource demand on clients Client DBMSs must recognize shared locks, integrity checks, etc. 5
Figure 9 -2 File server model FAT CLIENT Chapter 9 6
2. Two-Tier Database Server Architectures n Client is responsible for n I/O processing logic n Some business rules logic n Server performs all data storage and access processing DBMS is only on server Chapter 9 7
Advantages of Two-Tier Approach n n 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 9 8
Advantages of Stored Procedures n n n Compiled SQL statements 編譯後執行快 Reduced network traffic 佔較少的網路流量 Improved security 安全性較高 Improved data integrity 資料完整性較高 Thinner clients 前端運算量較少 Chapter 9 9
Figure 9 -3 Database server architecture (two-tier) Thinner clients DBMS only on server Chapter 9 10
3. Three-Tier Architectures Client GUI interface (I/O processing) Browser Application server Business rules Web Server Database server Data storage DBMS Thin Client l Chapter 9 PC just for user interface and a little application processing. Limited or no data storage (sometimes no hard drive) 例如: Web Browser 11
Figure 9 -4 a Generic three-tier architecture Thinnest clients Business rules on separate server DBMS only on DB server Chapter 9 12
Advantages of Three-Tier Architectures n n n Scalability (在佈署與效能上) 具擴充性 Technological flexibility 具技術彈性 Long-term cost reduction 長期低本降低 Better match of systems to business needs 較符合企業所需 Reduced risk 風險降低 Chapter 9 13
Application Partitioning n n Placing portions of the application code in different locations (client vs. server) AFTER it is written 重新切分程式執行的位置 Advantages Improved performance n Improved interoperability n Balanced workloads n Chapter 9 14
Common Logic Distributions Figure 9 -5 a Two-tier clientserver environments Processing logic could be at client, server, or both Figure 9 -5 b n-tier clientserver environment Processing logic will be at application server or Web server Chapter 9 15
Role of the Mainframe 大型主機 n n Mission-critical legacy systems tend to remain on mainframes When moving mission critical systems from mainframe to distributed client/server systems 例如: 銀行核心系統的移轉 n n Determining which code belongs on server vs. client Identifying potential conflicts with code from other applications Ensuring sufficient resources exist for anticipated load Rule of thumb 移轉的經驗法則 n n Mainframe for centralized data that does not need to be moved Client for data requiring frequent user access, complex graphics, and user interface Chapter 9 16
Benefits of Moving to Client/Server Architecture n n n 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 9 17
Middleware 中介軟體 n n n 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” that holds client/server applications together Chapter 9 18
Database Middleware n ODBC–Open n Database Connectivity Most DB vendors support this n JDBC–Java Database Connectivity 可視為Java版的ODBC n Special Java classes that allow Java applications/applets to connect to databases n OLE-DB n Microsoft enhancement of ODBC Chapter 9 19
Using ODBC to Link External Databases Stored on a Database Server n Open Database Connectivity (ODBC) n n Required parameters: n n n 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: n n n Data source name (DSN) Windows client computer name Client application program’s executable name Chapter 9 20
ODBC Architecture (Figure 9 -6) 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 9 21
Web/DB Application Components n Database server – hosts the DBMS n n Web server – receives and responds to browser requests using HTTP protocol n n e. g. Apache, MS IIS (Internet Information Services) Application server – software for creating dynamic web sites n n e. g. Oracle, MS SQL Server, MS Access, My. SQL e. g. MS ASP. NET framework, Java EE, PHP Web browser – client program that sends web requests and receives web pages n e. g. Internet Explorer, Firefox, Safari, Google Chrome Chapter 9 25
n Static page requests n n . htm or. html requests handled by the Web server Dynamic page requests. jsp, . aspx, and. php requests are routed to the application server n Server-side processing by JSP servlet, ASP. NET application, or PHP n Database access via JDBC, ODBC, ADO. NET, or other database middleware n Chapter 9 26
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 Chapter 9 © 2013 Pearson Education 27
- Slides: 27