7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
1/24
Copyright IBM Corporation 2004
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Welcome to:
3.1
Introduction to Databases and XMLIntroduction to Databases and XML
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
2/24
Copyright IBM Corporation 2004
Unit Objectives
After completing this unit, you should be able to:
List the characteristics of an XML document that help determine theright type of database
Define and describe content management databases
Compare relational database structures to XML documentstructures
List the limitations of relational data tables with structured data
Define and describe what Object-Oriented databases provide
Describe the status of XML-based queries
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
3/24
Copyright IBM Corporation 2004
Considerations
Start with what you are using the database for.
What type of application are you supporting? Is XML being used asa transport between the database and the application?
Are you using legacy data?
Are you more interested in the data or in the document structure?
Are you storing Web pages or Web pages' content?
Is your data used by other, perhaps non-XML, applications?
Are you updating the DB from XML?
Consider whether your XML document is moredata-centric or document-centric.
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
4/24
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
5/24 Copyright IBM Corporation 2004
Types of Databases
Relational Database (RDB) structures are not hierarchical. Muchof the world's current data exists in RDBs.
Object-Oriented Databases (OODB) are slow to catch on, but showpromise of storing XML data objects. Existing OODBs may havecomplex relationships.
Native XML database or content-management systems aredesigned specifically to store XML. Oriented towards thedocument-oriented XML systems.
Existing database systems must use some type of attachment orfilter to deal with XML data. Many RDB vendors are building thiscapability into their products.
Remember: An XML document is a hierarchical,ordered, and untyped document.
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
6/24 Copyright IBM Corporation 2004
XMLApps
Connect to Database using JDBC
Retrieve an SQL result set (text string) containingthe XML document
Use the XML parser to create XML DOM from theSQL result set
Use the XSLT processor to extract the requiredelement from the XML source tree
XML editing application to update theelement contents of the result DOM
Insert updated element object into source DOMUse XSLT to write DOM to SQL
Parse XML docs with SAX
Use JDBC to update the database
record
Java Application
Databaseback end
Typical Java-basedDatabase Interchange Solution
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
7/24
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
8/24 Copyright IBM Corporation 2004
XML to RDB - Where Should the Data Go?
X333
XML developers
Smith
John
250243
X333
Adams
Tom432453
X333
ID last first dept-nbr ...
250243 Smith John X333 ...
432453 Adams Tom X333
...
Employee
dept-nbr department-name
X333 XML developers
Z568 Human Resources
...
Department
Key XML_DocX333
X333XMLdevelopers
Smith ...Z568 Z568 ....
XML_Table
OR
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
9/24 Copyright IBM Corporation 2004
XML to RDB - And If We Have Attributes?
XML developers
SmithJohn
533-4333
Adams Tom
544-4444
ID last first dept-nbr ...
250243 Smith John X333 ...
432453 Adams Tom X333
...
Employee
dept-nbr department-name
X333 XML developers
Z568 Human Resources
...
Department
Key XML_Doc
X333
XML developers ...Z568
...
XML_Table
OR
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
10/24
O O
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
11/24 Copyright IBM Corporation 2004
Object-Oriented Databases
Object-Oriented Database (OODB) features:
Persistence of objects.Extend semantics of O-O programming languages.
Unification of data model and database structure.
Requires less code.
Ease of code base maintenance.
Relational Database (RDB) comparison:
Data structures must be flattened to fit joined tables.
Structures maintained in memory.
No built-in object management.
OODB real-world applications:
Risk analysis systems, telecom systems, WWW documentstructures, design and manufacturing systems, hospital patientrecord systems with complex data interrelationships.
XML N ti
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
12/24 Copyright IBM Corporation 2004
XML NativeDB/Content-management Systems (1 of 2)
Can be good for document-oriented XML, much less useful fordata-oriented XML.
Good for less structured data which could result in many nullcolumns in an RDB.
Preserves physical structure of document.
No need for schema or DTD.
Limited to XML interfaces.
Do not use for data serving a variety of applications.
And provide very fast retrieval speed for entire documents.
Search for specific views of data likely to be slower then RDB.
Can only return data as XML.
XML N ti
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
13/24
Copyright IBM Corporation 2004
XML NativeDB/Content-management Systems (2 of 2)
Two main categories:Text-based storage
Store the entire document.Provide limited DB function against the document.
Provide an exact roundtrip of the document.Model-based storage
Store a DOM presentation of the XML document into an existing orcustom data store. May use an RDB underneath.
Roundtrip at the level of the underlying model (can maintain order).
Wh t b t Ch t E di ?
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
14/24
Copyright IBM Corporation 2004
What about Character Encoding?
ASC II
EBCDIC
UTF-8
Convert?
Loss of
information?
CCSID
Different languages
SBCS
DBCS
Database
Unicode
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
15/24
Other Uses of XML with Databases
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
16/24
Copyright IBM Corporation 2004
Other Uses of XML with Databases
Describe databases:
TablesColumns
Foreign Keys
And so forth
Database exchange format.
Format for loading a database.
Example, different vendors
Represent result sets from database queries and updates forprograms and for humans.
Storing XML documents in databases as objects.
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
17/24
Database Schemas Example
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
18/24
Copyright IBM Corporation 2004
...
... Database Schema Example
CREATE TABLE employee
(emp_nbr Char(10)
NOT NULL PRIMARY KEY,
dept_nbr Char(6),
type Varchar(40),
last Varchar(40),
first Varchar(40));
Database Create Table
Database Schemas Example
XML Query Language (XQuery) (1 of 2)
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
19/24
Copyright IBM Corporation 2004
XML Query Language (XQuery) (1 of 2)
Goals
"The goal of the XML Query WG is to produce a data model forXML documents, a set of query operators on that data model, anda query language based on these query operators."
XQuery consists of six Working Drafts:
XQuery Requirements
XQuery Use Cases
XQuery 1.0 and XPath 2.0 Data Model
XQuery 1.0 Formal SemanticsXQuery 1.0: An XML Query Language
XML Syntax for XQuery 1.0 (XQueryX)
XML Query Language (XQuery) (2 of 2)
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
20/24
Copyright IBM Corporation 2004
XML Query Language (XQuery) (2 of 2)
XQuery Goals/Usage Scenarios
Human-readable documentsData-oriented documents
Mixed model documents
Administrative data
Stream filtering
DOM queries
Native XML repositories
Catalog searchMultiple syntactic environments
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
21/24
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
22/24
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
23/24
Unit Summary
7/25/2019 Lecture Introduction to XML: Introduction to Databases and XM
24/24
Copyright IBM Corporation 2004
In this unit we learned:
How to compare relational database structures to XML documentstructures.
The limitations of relational data tables with structured data.
What Object-Oriented databases provide.
The status of XML-based queries.
Unit Summary