Xquery XML Databases: Roger L. Costello 16 June 2010
Xquery XML Databases: Roger L. Costello 16 June 2010
Roger L. Costello
16 June 2010
2
XQuery Databases
• XQuery is an XML query language.
• It can be used to efficiently and easily
extract information from Native XML
Databases (NXD).
• It can be used to query XML views of
relational data.
3
Database Systems
supporting XQuery
• The following database systems offer XQuery
support:
– Native XML Databases:
• Berkeley DB XML
• eXist
• MarkLogic
• Software AG Tamino
• Raining Data TigerLogic
• Documentum xDb (X-Hive/DB)
– Relational Databases:
• IBM DB2
• Microsoft SQL Server
• Oracle
4
XML and
•4.0 Data versus Documents
•4.1 Data-Centric Documents
•4.2 Document-Centric Documents
•4.3 Data, Documents, and Databases
Databases
•5.0 Storing and Retrieving Data
•5.1 Mapping Document Schemas to Database Schemas
•5.1.1 Table-Based Mapping
•5.1.2 Object-Relational Mapping
•5.2 Query Languages
•5.2.1 Template-Based Query Languages
•5.2.2 SQL-Based Query Languages
•5.2.3 XML Query Languages
•5.3 Storing Data in a Native XML Database
•5.4 Data Types, Null Values, Character Sets, and All That Stuff
•5.4.1 Data Types
•5.4.2 Binary Data
•5.4.3 Null Data
•5.4.4 Character Sets
•5.4.5 Processing Instructions and Comments
•5.4.6 Storing Markup
•5.5 Generating XML Schemas from Relational Schemas and Vice Versa
•6.0 Storing and Retrieving Documents
•6.1 Storing Documents in the File System
•6.2 Storing Documents in BLOBs
•6.3 Native XML Databases
•6.3.1 What is a Native XML Database?
•6.3.2 Native XML Database Architectures
•6.3.2.1 Text-Based Native XML Databases
•6.3.2.2 Model-Based Native XML Databases
•6.3.3 Features of Native XML Databases
•6.3.3.1 Document Collections
•6.3.3.2 Query Languages
•6.3.3.3 Updates and Deletes
•6.3.3.4 Transactions, Locking, and Concurrency
•6.3.3.5 Application Programming Interfaces (APIs)
http://www.rpbourret.com/xml/XMLAndDatabases.htm •6.3.3.6 Round-Tripping
•6.3.3.7 Remote Data
•6.3.3.8 Indexes
7
http://markmail.org/
8
9
eXist
• It is a native XML database
• It is open source
• More info: http://exist-db.org
• Want to see some sample XQueries run against an
eXist database?
Check out the eXist sandbox:
http://demo.exist-db.org/exist/sandbox/sandbox.xql
• In the drop-down box labeled "Paste example" select
"Find books by author". Examine the XQuery then
press the Send button.
10
11
Installing eXist
• In your C: folder create a new folder, eXist
C:
eXist
• In the XQuery folder is a subfolder, eXist-exe-file. Open it. Double
click on the .exe file.
• The second prompt will ask: Select the installation path.
Enter: C:\eXist
• As the password for user ‘admin’ enter: admin
• Select these packs to install: Core, Javadocs (we don’t need
Source)
12
Running eXist
eXist Collections
• eXist organizes all documents in
hierarchical collections.
• Collections are like directories. They are
used to group related documents together.
• On the last slide you set the default
collection name to /db
16
Editing Resources
• Double clicking on FitnessCenter.xml allows you to
view and edit it:
21
for $i in doc('FitnessCenter.xml')//(*|@*)
return update rename node $i as lower-case(name($i))
Do Lab1