Home > Store

XML and SQL: Developing Web Applications

Register your product to gain access to bonus material or receive a coupon.

XML and SQL: Developing Web Applications


  • Sorry, this book is no longer in print.
Not for Sale


  • Copyright 2002
  • Dimensions: 7-3/8" x 9-1/4"
  • Edition: 1st
  • Book
  • ISBN-10: 0-201-65796-1
  • ISBN-13: 978-0-201-65796-8

As XML has rapidly gained in popularity, many database developers have become confused about its relationship with SQL and traditional RDBMS technologies. In this book, Dan Appelquist demystifies the relationship between XML and SQL, and shows exactly how to integrate these technologies for maximum advantage. XML and SQL covers every leading approach to integrating XML and SQL, helping you clearly understand each technology's strengths and weaknesses, and choose the right solution for each task or application. Drawing upon his extensive real-world experience, Appelquist offers expert guidance on: architecting robust systems that incorporate both XML and SQL technologies; using SQL to overcome XML's limitations; bringing XML's formatting capabilities to bear on SQL data, and much more. For all database developers, system architects, Web developers, content managers, and others interested in the use of XML to build robust, data-centric software systems.

Sample Content

Online Sample Chapter

Markup Languages: Why XML?

Downloadable Sample Chapter

Click below for Sample Chapter related to this title:

Table of Contents


Who Should Read This Book?

Why Would You Read This Book?

The Structure of This Book.

My Day Job in the Multimodal World.


About the Author.

1. Why XML?

The Lesson of SGML.

What About XML?

Why HTML Is Not the Answer.

The Basics of XML.

Why You Don't Need to Throw Away Your RDBMS.

A Brief Example.

Great! How Do I Get Started?


2. Introducing XML and SQL: A History Lesson of Sorts.

Extensible Markup Language (XML).

Evaluating XML's Design Goals.

Structured Query Language (SQL).

What Is “Relational”?

Fitting It All Together.


3. Project Definition and Management.

An Illustrative Anecdote.

How to Capture Requirements.

CyberCinema: The Adventure Begins.

Requirements Gathering.

User Scenarios.

Functional Requirements Document.

Quality Assurance.

Unit Testing.

Integration Testing.

Project Management.

Dynamic Systems Development Method (DSDM).

Extreme Programming!

The Technical Specification Document.


4 Data Modeling.

Getting Data-Centric.

Show Me the Data!

What Do You Hope to Accomplish?

Making It Visual: Entity Relationship Diagrams.

Roll Film: Back to CyberCinema.

Normalization Equals Power: Defining Relationships.

Keep It Simple: No Really, I Mean It.

Getting Complex: Many-to-One and Many-to-Many Relationships.

Another Layer of Complexity: Adding Media.


5. XML Design.

Carving Your Rosetta Stone.

When to Use XML and When Not to Use It.

Think Like an Archeologist.

Building a DTD.

CyberCinema: The Rosetta Stone Meets the Web.

The Head.

The Body.

Building XML DTDs: Let the Experts Do Hard Stuff.


6. Getting Relational: Database Schema Design.

Knowing When to Let Go.

First Steps.

SQL and XML: The Joys of Partial Decomposition.

Decomposing CyberCinema.

XML Nitro Injection: Adding Reviews.

Link Management.

Selecting What You Need.

Using Link Management to Help Power Suggestions.


7. Related Standards: XSLT, XML Schema, and Other Flora and Fauna.

XSLT: XML Transformers!

So How Does XSLT Work Exactly?

XML Schema: An Alternative to DTDs.

Querying XML Documents.

XML Query.

SQLX: The Truth Is Out There.


8. XML and SQL Server 2000.

Contributed by JJ Kuslich.

Retrieving Data in XML Format.




Communicating with SQL Server over the Web.

Under the Hood.

Retrieving Data in XML Format-Continued.

SQL Queries in URLs.

Template Files.

XPath Queries.

HTTP Post Queries.

XML Views.

Defining XML Views.

Let SQL Server Do the Work.

Working with XML Documents.



9. Java Programming with XML and SQL.

Dealing with XML in Java.

Building Java Objects for XML Instances with DOM.

Using SAX Events to Drive XML Partial Decomposition.

Invoking XSLT Transformations.

Designing an Entity Bean for Movie Reviews.

To Transform or Not to Transform.



Bean Persistence.

JDBC Advanced Data Types.

On the Near Horizon: XML Data Binding.

J2EE Application Servers.


10. More Examples: Beyond Silly Web Sites.

Building a Web Service.

Corporate Phone Directory.

Stock Quotes.


Taxonomical Structure.

Document Management and Content Locking.

Versioning and Change Management.




Index. 0201657961T11282001


This book is about how you can use Extensible Markup Language (XML) and relational databases in the real world to solve real problems (as opposed to the sometimes academic world of standards bodies and other groups that promote standards usage). In other words, you can really use XML--it's not just hype. In this book, you will find concrete examples, insight into the application development life cycle as I've known it, and a discussion of the why, the how, and the where of building applications (with a special focus on Web applications) using the tools of XML and relational databases.

This book is not intended to be a comprehensive guide. It's an overview of the field, packed with good ideas and witty commentary, which should get you started in the right direction. The areas I've focused the most attention on are ones in which I have something useful to say. In other areas, I've provided an overview of concepts, and, instead of reinventing the wheel, I've included URLs that point you to useful and informative Web resources.

Who Should Read This Book?This book is intended primarily for software developers who are managing small- to medium-scale projects. My experience is mostly from working on small development teams, where resource limitations often dictate that the person writing the requirements for a project is also the engineer in charge of design and coding. This book is written from that perspective. If you work in a larger, more structured team or environment, you may find it strange that I'm talking about requirements gathering in one sentence and data modeling in the next, but this book can also be useful to you, if applied correctly. I've organized the chapters into the different stages of application design so that you can read through the entire book or flip to a particular piece of interest. In either case, you'll come away with something useful.

Familiarity with the concepts of databases and markup languages (specifically, knowledge of HyperText Markup Language--HTML) will make this book easier to understand. If you're new to markup languages and SQL, you'll still find this book helpful in explaining how they can be used together to develop applications. In addition, I recommend you read XML: A Manager's Guide by Kevin Dick (1999) for an overview of the XML language and its features. I also recommend SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL by Michael J. Hernandez (2000).

Why Would You Read This Book?

Good question! I started writing this book after I worked on a content management application at TheStreet.com, which is an online financial news service--essentially an electronic newspaper--complete with journalists, editors, reporters, contributors, and columnists. TheStreet.com's publishing model was "multichannel"; they published their articles to their Web site (one "channel" of publication). They also published to other channels, such as syndicating articles to other sites (Microsoft Network, Yahoo!, and so forth) and to devices (PDAs, cell phones, pagers, what-have-you). This book is a result of my experiences in building a content management strategy for TheStreet.com and an application of everything I learned during that time, combined with in-depth material that I've picked up along the way. This book is best read when you're starting work on a project that has a content management component and you're thinking of using XML and a SQL database.

The Structure of This Book

This book is broken into ten chapters, corresponding roughly to the stages of application design and development.

1. Why XML? Notice I'm not asking the more mundane question, "What is XML?" This chapter instead delves into some specific examples of why XML is useful and why you want to start building systems with it.

2. Introducing XML and SQL: A History Lesson of Sorts. Chapter 2 provides a brief description of XML, its history and structure, and what it brings to the table. A similar discussion of SQL and the rise of the relational database follows.

3. Project Definition and Management. This chapter is a primer on getting the requirements for your system down on paper. It's included because I think this step is important, and I've often seen it done badly. Chapter 3 also discusses thinking about requirements from a perspective of building a "data-oriented" application. This chapter introduces two examples: a simple e-mail application and the CyberCinema Web site.

4. Data Modeling. After you have gathered your requirements, you have to start thinking abstractly about your data. It's a tough world out there, and without a bullet-proof data model to protect you, you're going to wake up one day and realize your life has been a dismal failure.

5. XML Design. You know why you should use XML because you read Chapter 1, but do you know where you should use it? What parts of your data make sense for XML, and what parts should remain purely relational? This chapter discusses the design of your XML documents, focusing on the document type definition (DTD) as a vehicle for this discussion.

6. Getting Relational: Database Schema Design. Now that you have your data model and your XML design, how do you best write a data schema to get the job done? This chapter is brimming with helpful examples.

7. Related Standards: XSLT, XML Schema, XML Query, and Other Flora and Fauna. What do you do with all this XML once you have it? This is where the Extensible Stylesheet Language (XSL) comes into play. XSL can be used to translate XML for display or internal purposes. It can also be leveraged to aid in partial decomposition. XML Schema provides an alternative to DTDs in defining XML document structure. Query languages on the near horizon promise to query XML documents and SQL databases.

8. XML and SQL Server 2000. So how do you take all this XML and relational data and turn it into a real, living, breathing application--one that's actually useful and works? Here's one answer: Use the comprehensive XML support found in Microsoft's SQL Server 2000. This chapter presents a discussion of those features and delves into how you might use them to implement some of the strategies previously discussed.

9. Java Programming with XML and SQL. Another implementation strategy for your XML applications is to build them using the J2EE (Java 2 Enterprise Edition) framework. Chapter 9 introduces this framework and discusses some of its XML-specific features.

10. More Examples: Beyond Silly Web Sites. Chapter 10 provides other concrete examples of how to mix XML and SQL harmoniously.



& (ampersand), 69-70, 138
/ (forward slash), 76
< (less-than symbol), 69
@ (percent sign), 137
+ (plus sign), 137
; (semicolon), 69
AABSTRACT element, 118
Abstraction layer, 175
Active user involvement, 42
ADO (Microsoft Active Data Objects), 134
Algorithms, data encoding, 84
Allaire JRun, 176
Amaya browser, 24. See also Browsers
American Express, xvii-xviii
ANSI (American National Standards Institute), 22
AOL (America Online), 23
Apache, 106, 176
Application(s). See also Application program interfaces (APIs)

building, essential steps to, 9-10
-centric thinking, 57
data-oriented design of, 50-51
development cycle for, 28
"killer," 18
supporting a wide variety of, as a design goal, 15
Application program interfaces (APIs), 180, 184
JAXP (Java API for XML Processing), 158, 159-160, 162, 165-166, 171-172
JDBC (Java DataBase Connection API), 134, 158-159, 162-163, 165, 172-175
SAX (Simple API for XML), 158-160, 163-165
Archeologists, 64, 66-68
basic description of, 21
multidimensional, 21
SQL data maps and, 22-23
Art Technology Group, 176
ASCII (American Standard Code for Information Interchange), 137
ASP (Microsoft Active Server Pages), 158
Astra, 42
ATG Dynamo, 176
ATTLIST keyword, 71
basic description of, 19, 64
IDs, 67-68
list declarations, 71
semantically encoded links and, 111-112
XLink and, 80
Audio CDs (compact discs), 4-5
AUTO mode, 132-133, 146, 147
b tag, 70
B2B (business-to-business) communications, xviii-xix
B2E (business-to-employee) communications, xix
Bandwidth, 17-18
base64 encoding, 84
BEA WebLogic, 176
Beck, Kent, 45
Berners-Lee, Tim, 12
Binary data. See also BLOBs (Binary Large Objects)
arbitrary, dealing with, 83-85
encoding, 84
formats, 16
pointing to, externally, 83
BLOBs (Binary Large Objects), 174-175
Body. See also BODY element
XLink and, 79-82
XML instance, 78-85
BODY element, 69, 70, 125. See also Body
Boldface font, 3, 13, 94
Bray, Tim, 80, 111
Bridging tables, 21, 103-104
Browsers. See also Internet Explorer browser (Microsoft)
HTTP and, 134
links and, 79, 105-107
URLs and, 137
XHTML and, 85
BR tag, 85
Bugs. See also Errors
schema and, 102
tracking, 41
Bugzilla, 41
C++ (high-level language), 158
Caching, 98-100, 171-172
Carlson, David, 38
Carriage returns, 74
CDATA (character data), 53, 69, 78
CDs (compact discs), 4-5
Census Bureau (United States), 50
CERN (European Center for Particle Physics), 12
Change management, 195-197
Character. See also CLOB (Character Large Object)
data (CDATA), 53, 69, 78
entities, 69-70
sets, 70
CHAR data type, 93
data modeling and, 57
DTDs as, 66
CLOB (Character Large Object), 93, 97, 174-175
commenting, 71
hard-coding, 6
Collaborative filtering, 110
Comments, 71
Communication styles, 34-35
Complexity, 58-60
Concise, use of the term, 17
Constitutional law, 11
integrity, 98
management, 95, 96, 98
Content authors, 112-113
Content model, 69, 74, 79, 201
Conversational style, 34-35
Corporate phone directory, 180-181
CREATE TABLE statement, 93, 96-98, 103
developers and, disconnect between, 42
requirements gathering and, 27-29
CyberCinema Web site
adding media to, 59-60
basic description of, 29-30
data modeling and, 49-61
decomposing, 100-113
DTD design and, 72-87, 201-207
functional requirements document for, 35-38
requirements gathering techniques and, 30-35
schema and, 91-114
user scenarios and, 30-33
binding, basic description of, 175
-centric approaches, 50-54
future-proofing, notion of, 2-3, 68
integrity, 90
management utilities, 99
Data types. See also Data types (listed by name)
attributes and, 19
data modeling and, 53
JDBC, 174-175
SQL, 93
Data types (listed by name). See also Data types
CHAR data type, 93
DATE data type, 103
TEXT data type, 93
varchar data type, 53, 93
create dates, 75
data type for, 103
DTDs and, 75, 77-78
last modified dates, 75
schema design and, 103
standards for, 77
two-digit, 17
use of the term, 75
Y2K issues and, 17
DBAs (database administrators), 68, 97
basic description of, 7, 95
caching and, 171
cautions for using, 83
of the CyberCinema Web site, 100-113
data synchronization and, 99
link management and, 107-108
partial, 94-100
problems with, 100
semantically encoded links and, 111-112
using SAX events to drive, 163-165
De facto standards, 24
DefaultHandler class, 163
De jure standards, 24
DELETE statement, 154
Dick, Kevin, xiv
-proofing, 68
recovery, 92
Document(s). See also DOM (Document Object Model); DTDs (document type definitions)
future-proofing, 2-3, 68
requirements, 35-42, 58, 59
working with, 152-154
DocumentBuilder object, 162
document tag, 8
DOM (Document Object Model)
basic description of, 159-160
building Java objects for XML instances with, 161-162
parser, 154, 158-160, 167
Domain-specific languages, 116
DSDM (Dynamic Systems Development Method), 42-43,
DSML (Directory Service Markup Language), 191
DTDs (document type definitions)
archives for, 86
basic description of, 63-66
building, 66-72, 85-86
comments and, 71
CyberCinema Web site and, 72-87, 201-207
data-oriented design and, 52
link management and, 107
processing without, 14-15
schema and, 91, 100, 101, 121-126
SQL Server and, 142
XML Views and, 142
Dummy files, creating, 67
Ease-of-use, importance if, 34
Easy recall, organizing data for, 96-98
E-business, 26-27, 185-188
EDI (Electronic Data Interchange), 117
Editors, 65
E-Doc, 1-2
EJBs (Enterprise Java Beans)
basic description of, 158, 166-170
JDBC and, 172-175
persistence of, 174
ELEMENT keyword, 69
Elements. See also Elements (listed by name); Tags
basic description of, 64
empty, 76
organizing, within blocks, 75-78
Elements (listed by name). See also Elements
ABSTRACT element, 118
BODY element, 69, 70, 125
FROM element, 69
HEAD element, 74-78, 125
MOVIE element, 81, 107, 125
PERSON element, 81, 107, 125
REVIEW element, 81, 125
SUBJECT element, 69, 70
TO element, 69
ElementType definition, 151
E-mail systems, 40, 96-99
building DTDs for, 68-72
data modeling and, 52-54
fields for, 52-53, 60, 67, 68, 71
numerical ID numbers and, 67-68
requirements and, 27-29
schema and, 91-114
Emergent property, use of the term, xviii-xix
em tag, 13, 14, 118-119
ENC (Environment Naming Context), 173
endDocument method, 163
endElement method, 163
references, 69-70
relationship diagrams, 54
sets, 69-70
Errors. See also Bugs
dead link, 105
decomposition and, 98
URLs and, 105, 137
Essential use cases, 37. See also Use cases
Expectations, managing, 27
EXPLICIT mode, 132-134, 146
Extreme programming (XP), 43-45
Extreme Programming Explained (Beck), 45
Fields, for e-mail messages, 52-53, 60, 67, 68, 71
Filtering, collaborative, 110
Flags, 83
Flash (Macromedia), 24
Fonts, 3, 70, 94, 201
FOR XML AUTO clause, 132-133
FOR XML clause, 131-132, 136, 146, 147
FOR XML EXPLICIT clause, 133-134, 143
Founding Fathers, 11
FROM element, 69
Functionality, 90


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020