+ All Categories
Home > Documents > © 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 8: Database Application...

© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 8: Database Application...

Date post: 01-Jan-2016
Category:
Upload: homer-houston
View: 217 times
Download: 2 times
Share this document with a friend
Popular Tags:
41
© 2011 Pearson Education, Inc. Publishing as © 2011 Pearson Education, Inc. Publishing as Prentice Hall Prentice Hall 1 Chapter 8: Chapter 8: Database Application Database Application Development Development Modern Database Management Modern Database Management 10 10 th th Edition Edition Jeffrey A. Hoffer, V. Ramesh, Jeffrey A. Hoffer, V. Ramesh, Heikki Topi Heikki Topi
Transcript

© 2011 Pearson Education, Inc.  Publishing as Prentice © 2011 Pearson Education, Inc.  Publishing as Prentice HallHall 11

Chapter 8:Chapter 8: Database Application Database Application

DevelopmentDevelopment

Modern Database Modern Database ManagementManagement

1010thth Edition EditionJeffrey A. Hoffer, V. Ramesh, Jeffrey A. Hoffer, V. Ramesh,

Heikki TopiHeikki Topi

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 22

ObjectivesObjectives Define termsDefine terms Explain three components of client/server systems: Explain three components of client/server systems:

presentation, processing, and storagepresentation, processing, and storage Distinguish between two-tier and three-tier architecturesDistinguish between two-tier and three-tier architectures Describe how to connect to databases in 2-tier systems Describe how to connect to databases in 2-tier systems

using VB.NET and Javausing VB.NET and Java Describe key components and information flow in Web Describe key components and information flow in Web

applicationsapplications Describe how to connect to databases in 3-tier applications Describe how to connect to databases in 3-tier applications

using JSP, PHP, and ASP .NETusing JSP, PHP, and ASP .NET Explain the purpose of XMLExplain the purpose of XML See how XQuery can be used to query XML documentsSee how XQuery can be used to query XML documents Explain how XML fosters Web services and SOAsExplain how XML fosters Web services and SOAs

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 33

Client/Server SystemsClient/Server Systems

Networked computing modelNetworked computing model Processes distributed between clients Processes distributed between clients

and serversand servers 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 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 44

Application Logic in C/S Application Logic in C/S SystemsSystems

GUI Interface

Procedures, functions,programs

DBMS activities

Processing LogicProcessing Logic I/O processingI/O processing Business rulesBusiness rules Data managementData management

Storage LogicStorage Logic Data storage/retrievalData storage/retrieval

Presentation LogicPresentation Logic Input–keyboard/mouseInput–keyboard/mouse Output–monitor/printerOutput–monitor/printer

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 55

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 writtenserver) after it is written

AdvantagesAdvantages Improved performanceImproved performance Improved interoperabilityImproved interoperability Balanced workloadsBalanced workloads

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 66

Figure 8-2 Common Logic DistributionsFigure 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 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 77

Figure 8-2 Common Logic DistributionsFigure 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 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 88

Two-Tier Database Server Two-Tier Database Server ArchitecturesArchitectures

Client workstation is responsible for Client workstation is responsible for Presentation logicPresentation logic Data processing logicData processing logic Business rules logicBusiness rules logic

Server performs all data storage, Server performs all data storage, access, and processing access, and processing Typically called a Typically called a database serverdatabase server

DBMS is only on serverDBMS is only on server

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 99

Figure 8-3 Database server architecture (two-tier architecture)

Front-end programs

Back-end functions

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 1010

Characteristics of Two-Tier Characteristics of Two-Tier Client/Server SystemsClient/Server Systems

Departmental in scope (few users)Departmental in scope (few users) Not mission-criticalNot mission-critical Low transaction volumesLow transaction volumes Common programming languages: Common programming languages:

Java, VB .NET, C#Java, VB .NET, C# Interface database via middleware, Interface database via middleware,

APIsAPIs

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall

Middleware and APIsMiddleware and APIs Middleware – software that allows an Middleware – software that allows an

application to interoperate with other application to interoperate with other software without requiring user to understand software without requiring user to understand and code low-level operationsand code low-level operations

Application Program Interface (API) – routines Application Program Interface (API) – routines that an application uses to direct the that an application uses to direct the performance of procedures by the computer’s performance of procedures by the computer’s operating systemoperating system

Common database APIs – ODBC, ADO .NET, Common database APIs – ODBC, ADO .NET, JDBCJDBC

1111

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall

Steps for Using Databases Steps for Using Databases via Middleware APIsvia Middleware APIs

1.1. Identify and register a database driver.Identify and register a database driver.

2.2. Open a connection to a database.Open a connection to a database.

3.3. Execute a query against the database.Execute a query against the database.

4.4. Process the results of the query.Process the results of the query.

5.5. Repeat steps 3–4 as necessary.Repeat steps 3–4 as necessary.

6.6. Close the connection to the database.Close the connection to the database.

1212

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 1313

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 1414

Three-Tier ArchitecturesThree-Tier Architectures

Thin Client PC just for user interface and a little application

processing. Limited or no data storage (sometimes no hard drive)

GUI interface (I/O processing)

Browser

Business rules Web Server

Data storage DBMS

ClientClient

Application serverApplication server

Database serverDatabase server

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 1515

Figure 8-6a Generic three-tier architecture

Thin Thin clientsclients

Business rules Business rules on applicationon applicationserverserver

DBMS only DBMS only on DB serveron DB server

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall

Thin ClientThin Client

An application where the client (PC) An application where the client (PC) accessing the application primarily accessing the application primarily provides the user interfaces and some provides the user interfaces and some application processing, usually with no application processing, usually with no or limited local data storage.or limited local data storage.

Most commonly, the thin client Most commonly, the thin client application is a Web browser and the 3-application is a Web browser and the 3-tier architecture involves a Web tier architecture involves a Web application.application.

1616

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 1717

Figure 8-7 A database-enabled intranet/Internet environment

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall

Web Application Web Application ComponentsComponents Database server – hosts the DBMSDatabase server – hosts the DBMS

e.g. Oracle, SQL Server, Informix, MS Access, MySqle.g. Oracle, SQL Server, Informix, MS Access, MySql Web server – receive and respond to browser Web server – receive and respond to browser

requests using HTTP protocolrequests using HTTP protocol e.g. Apache, Internet Information Services (IIS)e.g. Apache, Internet Information Services (IIS)

Application server – software building blocks for Application server – software building blocks for creating dynamic web sitescreating dynamic web sites e.g. MS ASP .NET framework, Java EE, ColdFusion, PHPe.g. MS ASP .NET framework, Java EE, ColdFusion, 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

1818

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 1919

Languages for Creating Web Languages for Creating Web PagesPages

Hypertext Markup Language (HTML)Hypertext Markup Language (HTML) Markup language specifically for Web pagesMarkup language specifically for Web pages

Standard Generalized Markup Language (SGML)Standard Generalized Markup Language (SGML) Markup language standardMarkup language standard

Extensible Markup Language (XML)Extensible Markup Language (XML) Markup language allowing customized tagsMarkup language allowing customized tags

XHTMLXHTML XML-compliant extension of HTMLXML-compliant extension of HTML

JavaScript/VBScriptJavaScript/VBScript Scripting languages that enable interactivity in HTML documentsScripting languages that enable interactivity in HTML documents

Cascading Style Sheets (CSS)Cascading Style Sheets (CSS) Control appearance of Web elements in an HML documentControl appearance of Web elements in an HML document

XSL and XSLTXSL and XSLT XMS style sheet and transformation to HTMLXMS style sheet and transformation to HTML

Standards and Web conventions established

byWorld Wide Web World Wide Web

Consortium (W3C)Consortium (W3C)

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall

Processing in 3-Tier Processing in 3-Tier ApplicationsApplications

Static page requests Static page requests .htm or .html requests are handled by the Web .htm or .html requests are handled by the Web

server only server only 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, ColdFusion, or PHPapplication, ColdFusion, or PHP

Database access via JDBC, ADO .NET, or other Database access via JDBC, ADO .NET, or other database middlewaredatabase middleware

2020

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 2121

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 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 2222

Figure 8-12 A registration page written in Figure 8-12 A registration page written in ASP .NETASP .NET

a) Sample ASP .NET code for user registration

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 2323

Figure 8-12 A registration page written in Figure 8-12 A registration page written in ASP .NETASP .NET

b) Form for the ASP .NET application

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall

Considerations in 3-Tier Considerations in 3-Tier ApplicationsApplications

Stored proceduresStored procedures Code logic embedded in DBMSCode logic embedded in DBMS Improve performance, but proprietaryImprove performance, but proprietary

TransactionsTransactions Involve many database updatesInvolve many database updates Either all must succeed, or none should occurEither all must succeed, or none should occur

Database connectionsDatabase connections Maintaining an open connection is resource-intensiveMaintaining an open connection is resource-intensive Use of connection poolingUse of connection pooling

2424

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 2525

Benefits of Stored Benefits of Stored ProceduresProcedures

Performance improves for Performance improves for compiled SQL statementscompiled SQL statements

Reduced network trafficReduced network traffic Improved securityImproved security Improved data integrityImproved data integrity Thinner clientsThinner clients

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 2626

Benefits of Three-Tier Benefits of Three-Tier ArchitecturesArchitectures

ScalabilityScalability Technological flexibilityTechnological flexibility Long-term cost reductionLong-term cost reduction Better match of systems to business Better match of systems to business

needsneeds Improved customer serviceImproved customer service Competitive advantageCompetitive advantage Reduced riskReduced risk

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 2727

Extensible Markup Language Extensible Markup Language (XML)(XML)

A text-based markup language (like HTML)A text-based markup language (like HTML) Uses elements, tags, attributesUses elements, tags, attributes Includes document type declarations (DTDs), Includes document type declarations (DTDs),

XML schemas, comments, and entity referencesXML schemas, comments, and entity references Revolutionizes the way data are exchanged Revolutionizes the way data are exchanged

over the Internetover the Internet Document Structure Declarations (DSD), Document Structure Declarations (DSD),

XML Schema (XSD) and Relax NG replacing XML Schema (XSD) and Relax NG replacing DTDs for validating XML document structureDTDs for validating XML document structure

XSD – language for defining XML databases, XSD – language for defining XML databases, recommended by the W3Crecommended by the W3C

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 2828

Sample XML Schema (XSD)Sample XML Schema (XSD)

Schema is a record definition, analogous to the Create SQL statement, and therefore provides metadata

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 2929

Sample XML Document Sample XML Document DataData

This XML data conforms to the XML schema of the previous slide, and involves elements and attributes defined in the schema.

This is analogous to a record in a database

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 3030

Another Sample XML Another Sample XML DocumentDocument

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall

Storing XML DocumentsStoring XML Documents Storing as files introduces the same file Storing as files introduces the same file

processing problems stated in Ch 1processing problems stated in Ch 1 Four common options:Four common options:

Store XML data in a relational database by Store XML data in a relational database by shredding the XML documentshredding the XML document

Store an entire XML document in a large field Store an entire XML document in a large field (BLOB or CLOB)(BLOB or CLOB)

Store the XML document using special XML columnsStore the XML document using special XML columns Store the XML document using a native XML Store the XML document using a native XML

database (non-relational)database (non-relational)

3131

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall

Retrieving XML DocumentsRetrieving XML Documents XPath – One of a set of XML technologies XPath – One of a set of XML technologies

supporting XQuery development, locating supporting XQuery development, locating data in XML documentsdata in XML documents

XQuery – An XML transformation language XQuery – An XML transformation language that allows applications to query both that allows applications to query both relational databases and XML datarelational databases and XML data

Sample XQuery expression:Sample XQuery expression:

3232

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall

Displaying XML DataDisplaying XML Data Extensible Stylesheet Language Extensible Stylesheet Language

Transformation (XSLT) – A language used to Transformation (XSLT) – A language used to transform complex XML documents and also transform complex XML documents and also used to create HTML pages from XML used to create HTML pages from XML documentsdocuments

XSLT can translate a single XML document XSLT can translate a single XML document into both standard HTML and WAP/WML for into both standard HTML and WAP/WML for cell phones without the necessity for two cell phones without the necessity for two different pagesdifferent pages

3333

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall

Figure 8-15b – XSLT Code

3434

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 3535

Extracted from Figures 8a and 8c

When applied to the above XML data, the XSLT code from Figure 8b produces the display on the right.

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall

XML and Web ServicesXML and Web Services Web Services Web Services – a set of emerging XML-based standards – a set of emerging XML-based standards

that define protocols for automatic communication between that define protocols for automatic communication between software programs over the Web software programs over the Web

Universal Description, Discovery, and Integration Universal Description, Discovery, and Integration (UDDI(UDDI) – standard for creating and distributing Web services) – standard for creating and distributing Web services

Web Services Description Language (WSDL) Web Services Description Language (WSDL) – XML-– XML-based grammar for describing a Web Service and specifying based grammar for describing a Web Service and specifying its public interfaceits public interface

Simple Object Access Protocol (SOAP)Simple Object Access Protocol (SOAP) – XML-based – XML-based communication protocol for sending messages between communication protocol for sending messages between applications over the Internetapplications over the Internet

3636

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 3737

Figure 8-17 Web Services protocol stack

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 3838

SOAP request sent from customer to supplier

SOAP response sent from supplier to customer

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 3939

Figure 8-18 Web services deployment

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall

Service Oriented Architecture Service Oriented Architecture (SOA)(SOA)

A collection of services that communicate A collection of services that communicate with each other in some manner, usually by with each other in some manner, usually by passing data or coordinating a business passing data or coordinating a business activityactivity

A new paradigm for IT application A new paradigm for IT application development, based mostly on Web servicesdevelopment, based mostly on Web services

Loosely coupled, highly interoperable Loosely coupled, highly interoperable componentscomponents

Leads to flexibility and shorter development Leads to flexibility and shorter development timetime

4040

Chapter 8 © 2011 Pearson Education, Inc.  Publishing as Prentice Hall© 2011 Pearson Education, Inc.  Publishing as Prentice Hall 4141

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic,

mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America.

Copyright © 2011 Pearson Education, Inc.  Publishing as Prentice Copyright © 2011 Pearson Education, Inc.  Publishing as Prentice HallHall


Recommended