Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
MUSA M.AMEEN
18/12/2014
Outlines
 Introduction
 Why XML for databases?
 What's XML database?
 XML Structure
 Types of XML databases
 XML vs....
Introduction
 Data interchange is critical in today’s networked world
 Each application area has its own set of standard...
Why XML for databases?
 It is more suitable for specifying structured data that is
extracted from databases than HTML
 X...
What’s XML?
 XML stands for Extensible Markup Language.
 It is designed to describe data and focus on what data is.
 It...
<?xml version = "1.0"?>
Structure of XML Data
<library xmlns:mevlana=“http://mevlana.edu.tr”>
<book id="bk101">
<author>Ga...
Types of XML databases
There are two major types of XML databases:
 XML-enabled: These map all XML to a traditional datab...
XML vs. Relational Database
XML Database
 XML data is hierarchical
 XML data is self-describing
 XML data has inherent
...
XML vs. Relational Database
9
<ORDER>
<ORDER_ID=’83492’ CUST_ID=’93457’>
<ITEM>
<PROD_ID>94872</PROD_ID>
<PROD_NAME>PEN</P...
XML Representation
10
XML Document Schema
 Database schemas constrain what information can be stored,
and the data types of stored values
 XML...
Document Type Definition
 DTD constraints structure of XML data
 What elements can occur
 What attributes can/must an e...
Document Type Definition
13
DTD XML
XML Schema Definition
 Different data types
 XML Schema is itself specified in XML syntax, unlike DTDs
 XML Schema is i...
XML Schema Definition
15
XSD XML
Querying XML Data
 There are several languages used to access XML data from XML
Documents, some are:
 XPath
 Xquery (mo...
XPath
 XPath is used to address (select) parts of documents using path
expressions
17
<?xml version="1.0">
<bookstore>
<b...
XQuery
 XQuery is a general purpose query language for XML data
 XQuery is built on XPath expressions
 XQuery is derive...
XQuery
19
<?xml version="1.0">
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Gia...
Demo
 Demonstration of XML Database using eXistdb
20
Upcoming SlideShare
Loading in …5
×

XML Databases

5,908 views

Published on

XML Databases

Published in: Engineering
  • Be the first to comment

XML Databases

  1. 1. MUSA M.AMEEN 18/12/2014
  2. 2. Outlines  Introduction  Why XML for databases?  What's XML database?  XML Structure  Types of XML databases  XML vs. Relational databases  Document Type Definition  XML Schema Definition  Xpath  Xquery  Demo 2
  3. 3. Introduction  Data interchange is critical in today’s networked world  Each application area has its own set of standards for representing information  XML has become the basis for all new generation data interchange formats  Earlier generation formats were based on plain text with line headers indicating the meaning of fields 3
  4. 4. Why XML for databases?  It is more suitable for specifying structured data that is extracted from databases than HTML  XML was developed was to allow the exchange of semi- structured documents.  Using a database system to store XML documents allows users to be able to better access information.  XML is also very flexible  Data is maintained in a self-describing format to accommodate a variety of ever-evolving business needs. 4
  5. 5. What’s XML?  XML stands for Extensible Markup Language.  It is designed to describe data and focus on what data is.  It is used to structure store and to send information.  It is easy to understand and is self describing.  XML is derived from Standard Generalized Markup Language (SGML) 5
  6. 6. <?xml version = "1.0"?> Structure of XML Data <library xmlns:mevlana=“http://mevlana.edu.tr”> <book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> </book> </library> <!-- comments --> 6 Start tag End tag Element Attribute Namespace Comments tag XML Document Node
  7. 7. Types of XML databases There are two major types of XML databases:  XML-enabled: These map all XML to a traditional database, accepting XML as input and rendering XML as output.  Native XML (NXD): The internal model depends on XML and uses XML documents as the fundamental unit of storage. 7
  8. 8. XML vs. Relational Database XML Database  XML data is hierarchical  XML data is self-describing  XML data has inherent ordering  An XML database contains collections 8 Relational Database  relational data is represented in a model of logical relationships  relational data is not self- describing  Relational data does not have inherent ordering  A relational database contains tables
  9. 9. XML vs. Relational Database 9 <ORDER> <ORDER_ID=’83492’ CUST_ID=’93457’> <ITEM> <PROD_ID>94872</PROD_ID> <PROD_NAME>PEN</PROD_NAME> <PRICE>19.95</PRICE> <QUANTITY>30</QUANTITY> </ITEM> <ITEM> <PROD_ID>94866</PROD_ID> <PROD_NAME>BINDER</PROD_NAM E> <PRICE>7.95</PRICE> <QUANTITY>26</QUANTITY> </ITEM> <ITEM> <PROD_ID>92219</PROD_ID> <PROD_NAME>LABELS</PROD_NAM E> <PRICE>12.95</PRICE> <QUANTITY>250</QUANTITY> </ITEM> Items Order
  10. 10. XML Representation 10
  11. 11. XML Document Schema  Database schemas constrain what information can be stored, and the data types of stored values  XML documents are not required to have an associated schema  Schemas are very important for XML data exchange  Two mechanisms for specifying XML schema  Document Type Definition (DTD)  XML Schema Definition (XSD) 11
  12. 12. Document Type Definition  DTD constraints structure of XML data  What elements can occur  What attributes can/must an element have  What subelements can/must occur inside each element, and how many times.  DTD does not constrain data types 12
  13. 13. Document Type Definition 13 DTD XML
  14. 14. XML Schema Definition  Different data types  XML Schema is itself specified in XML syntax, unlike DTDs  XML Schema is integrated with namespaces  XML Schema is significantly more complicated than DTDs 14 XML Schema is a more sophisticated schema language which addresses the drawbacks of DTDs. Supports
  15. 15. XML Schema Definition 15 XSD XML
  16. 16. Querying XML Data  There are several languages used to access XML data from XML Documents, some are:  XPath  Xquery (most popular)  XML-QL  XQL  etc.... 16
  17. 17. XPath  XPath is used to address (select) parts of documents using path expressions 17 <?xml version="1.0"> <bookstore> <book> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore> Document node Element node Attribute node /bookstore Will select the root element bookstore /bookstore/book Selects all book elements that are children of bookstore /bookstore/book/text() Selects all book elements of bookstore without tags
  18. 18. XQuery  XQuery is a general purpose query language for XML data  XQuery is built on XPath expressions  XQuery is derived from the quilt query language, which itself borrows from SQL  XQuery is supported by all database engines (IBM, Oracle, Microsoft, etc.)  XQuery uses FLOWR (for, let, where, order by , result)  for  SQL from  where  SQL where  order by  SQL order by  result  SQL select  let allows temporary variables 18
  19. 19. XQuery 19 <?xml version="1.0"> <bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> </bookstore> for $x in doc("books.xml")/bookstore/book where $x/price>29 return $x/title Select title From bookstore/book Where price>29
  20. 20. Demo  Demonstration of XML Database using eXistdb 20

×