XML and The Relational Data Model

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
An Introduction to XML Based on the W3C XML Recommendations.
XQuery John Annechino Steven Pow. Agenda What is XQuery? Uses of XQuery XQuery vs. XSLT Syntax –Built-In Functions –FLWOR –if-then-else –User-Defined.
XQuery Or, what about REAL databases?. XQuery - its place in the XML team XLink XSLT XQuery XPath XPointer.
XQUERY. What is XQuery? XQuery is the language for querying XML data The best way to explain XQuery is to say that XQuery is to XML what SQL is to database.
1 XQuery Web and Database Management System. 2 XQuery XQuery is to XML what SQL is to database tables XQuery is designed to query XML data What is XQuery?
XML XML What XML is and what it means to me as a Computer Scientist By: Derek Edwards CS 376 March 10, 2003.
Paper by: A. Balmin, T. Eliaz, J. Hornibrook, L. Lim, G. M. Lohman, D. Simmen, M. Wang, C. Zhang Slides and Presentation By: Justin Weaver.
IS 373—Web Standards Todd Will
1 COS 425: Database and Information Management Systems XML and information exchange.
1 New Ways of Querying the Web by Eliahu Brodsky and Alina Blizhovsky.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
Introduction to XML This material is based heavily on the tutorial by the same name at
1 Advanced Topics XML and Databases. 2 XML u Overview u Structure of XML Data –XML Document Type Definition DTD –Namespaces –XML Schema u Query and Transformation.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
4/20/2017.
ECA 228 Internet/Intranet Design I Intro to XML. ECA 228 Internet/Intranet Design I HTML markup language very loose standards browsers adjust for non-standard.
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
 Introduction to XML Introduction to XML  Features of XML Features of XML  Syntax of XML Syntax of XML  Syntax rules of XML document Syntax rules.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 XML Taken from Chapter 7.
WPF chapter 15 Dr. John Abraham Professor UTPA. WPF –an introduction WPF provides a single platform capable of handling graphics, audio and video. WPF.
Lecture 21 XML querying. 2 XSL (eXtensible Stylesheet Language) In HTML, default styling is built into browsers as tag set for HTML is predefined and.
XML: Overview MIS 181.9: Service Oriented Architecture 2 nd Semester,
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
Another PillowTalk Presentation  2004 Dynamic Systems, Inc. Introduction to XML for SOA Lee H. Burstein,
XML Overview. Chapter 8 © 2011 Pearson Education 2 Extensible Markup Language (XML) A text-based markup language (like HTML) A text-based markup language.
Extensible Markup and Beyond
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
28 October 2008CIS 340 # 1 Topics To define XML as a technology To place XML in the context of system architectures Online support:
Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham.
Waqas Anwar Next SlidePrevious Slide. Waqas Anwar Next SlidePrevious Slide XML XML stands for EXtensible Markup Language.
Database Systems Part VII: XML Querying Software School of Hunan University
[ Part III of The XML seminar ] Presenter: Xiaogeng Zhao A Introduction of XQL.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
An Introduction to XML Sandeep Bhattaram
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
The eXtensible Markup Language (XML). Presentation Outline Part 1: The basics of creating an XML document Part 2: Developing constraints for a well formed.
XML Introduction. Markup Language A markup language must specify What markup is allowed What markup is required How markup is to be distinguished from.
The Semistructured-Data Model Programming Languages for XML Spring 2011 Instructor: Hassan Khosravi.
XML and Database.
CS 157B: Database Management Systems II February 11 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
XML e X tensible M arkup L anguage (XML) By: Albert Beng Kiat Tan Ayzer Mungan Edwin Hendriadi.
Submitted To: Ms. Poonam Saini, Asst. Prof., NITTTR Submitted By: Rohit Handa ME (Modular) CSE 2011 Batch.
XML A Language Presentation. Outline 1. Introduction 2. XML 2.1 Background 2.2 Structure 2.3 Advantages 3. Related Technologies 3.1 DTD 3.2 Schemas and.
DTD ]>. Internal DTD Declaration ]> Faculty Director Reminder Please be regular in your classes.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
XML – Basic Concepts (modified version from Dr. Praveen Madiraju) 2015, Fall Pusan National University Ki-Joune Li.
XML Extensible Markup Language
XML Introduction to XML Extensible Markup Language.
XQUERY The contents of this slide are obtained from various sources including, Wikipedia, W3School, Stanford website etc. January 2011 Dr.Kwanchai Eurviriyanukul.
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
XML. What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display data.
XML Databases Presented By: Pardeep MT15042 Anurag Goel MT15006.
Extensible Markup Language (XML) Pat Morin COMP 2405.
XML intro. What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display.
XML BASICS and more…. What is XML? In common:  XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed.
XML: Extensible Markup Language
XML QUESTIONS AND ANSWERS
XML in Web Technologies
Database Processing with XML
Database.
CSE591: Data Mining by H. Liu
Presentation transcript:

XML and The Relational Data Model <author> By: Soid Quintero </author>

Overview Define XML XML model vs. relational model XML Documents Xpath XQuery Going from XML to the relational model

What is XML? Include and example of an XML document XML stands for Extensible Markup Language It is a metalanguage used to represent and manipulate data elements Similar to HTML in structure, but XML is concerned with the description and representation of data, rather than with the way it is displayed. XML is derived from Standard Generalized Markup Language (SGML)‏ XML data is used to create XML documents. Include and example of an XML document subset of SGML, SGML is very complex

Why XML for databases? One of the main reasons that XML was developed was to allow the exchange of semi-structured documents, like invoices, order forms, applications, etc., over the internet. 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. Not just the internet but different applications, platforms, and so on.

What is an XML Database? Simply a database that stored XML Documents There are two major types of XML databases: XML-enabled. These map all XML to a traditional database (such as a database), accepting XML as input and rendering XML as output. Native XML (NXD) The internal model of such databases depends on XML and uses XML documents as the fundamental unit of storage. A database that stores XML documents. There are two types. The first is the "XML-enabled database," which is a relational or object-oriented database that has been extended to hold XML data. In this method, there is always a conversion to and from the XML document to the underlying structure such as rows and columns in the relational model. In addition, the XML-enabled database may only store part of the XML document. The second is the "native XML database," which indexes XML documents directly and stores the entire XML document and related elements. Depending on the application, the native XML database may provide better performance than the XML-enabled database. For more information on XML databases

XML Model VS. Relational Model? XML data is hierarchical XML data is self-describing XML data has inherent ordering An XML database contains collections 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 As we have already learned about the relational data model we know that it is made up of relations (tables), attributes (columns)‏ A relational record is an unordered list of named values An XML document is a tree of nodes

Relational Model Order of rows is not guaranteed unless the ORDER clause is used in one or more columns Relations (tables)‏ Data is represented in n-ary relations. Has a domain that represents a set of values Attributes (columns)‏ Strict schema Restrictive The strict schema insures data integrity

XML Model The XML Model is hierarchical format Data is represented in trees structures There's nodes Relationships between the node The schema provides flexibility Easily modified format

multiple elements represented in a hierarchy, including a root“Comments” element and one or more individual “Comment” elements pertaining to a given item.

XML Document Rules XML documents must be well formated, meaning that every opening tag needs a closing tag (ex. <Student> </Student> )‏ It allows users to define their own tags (unlike HTML)‏ The XML tags need to be properly nested. The XML and xml tags are reserved for XML tags only. You can use <-- XXX --> symbols for comments XML is case sensitive so, <Student> is not the same as <STUDENT> Two types of XML documents commonly used, Document Type Definition (DTD) or an XML Schema Definitions (XSD) * Well-formed. A well-formed document conforms to all of XML's syntax rules. * Valid. A valid document additionally conforms to some semantic rules. These rules are either user-defined, or included as an XML schema or DTD. (wikipedia)‏

What is a Document Type Definition? DTDs can be declared inline of the XML code or can reference an external file It provides the composition of the database's logical model and defines the syntax rules or valid tags for each type of XML document. A DTD is a file that has a .dtd extension. This file describes XML elements. PCDATA Parsed character data: It refers to "usual" characters of the document without any markup tags and can be used to explicitly allow or disallow plain text within an element. Always needs to be in '( )' Example of a DTD on next slide.......

Inline DTD External DTD message.xml message.xml message.dtd <?xml version="1.0"?> <!DOCTYPE message SYSTEM "message.dtd"> <message> <to>Dave</to> <from>Susan</from> <subject>Reminder</subject> <text>Don't forget to buy milk on the way home.</text> </message> <?xml version="1.0"?> <!DOCTYPE message [ <!ELEMENT message (to,from,subject,text)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT subject (#PCDATA)> <!ELEMENT text (#PCDATA)> ]> <message> <to>Dave</to> <from>Susan</from> <subject>Reminder</subject> <text>Don't forget to buy milk on the way home.</text> </message> message.dtd <?xml version="1.0"?> <!ELEMENT message (to,from,subject,text)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT subject (#PCDATA)> <!ELEMENT text (#PCDATA)>

What is an XML Schema Definition? The XML Schema is an advance definition language that is used to describe the structure (elements, data types, relationships types, ranges, and default values)‏ It is an alternative to DTD Since data types are allowed data validation is possible and easier to do. A XSD file has a .xsd extension Point out the different between DTD and XSD. Validation vs. no data validation. Example of a XSD on next slide.......

The first line is needed. Point out importance of formating for XSD. <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified"> <xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> The first line is needed. Point out importance of formating for XSD.

How do you access XML data? There are several languages used to access XML data from XML Documents, some are: XPath XQuery XML-QL XQL etc....

XPath Xpath is a language used to extract parts of an XML document. XPath uses path expressions to navigate in XML documents Xpath has 7 kinds of nodes: Element Attribute Text Namespace Processing-Instruction Comment Document(root)

Examples of XPath <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore> Document node Attribute node Element node Example of an XPath expressions: /bookstore Will select the root element bookstore /bookstore/book Selects all book elements that are children of bookstore

XQuery Think of XQuery as SQL for a relational database for XML. XQuery is a language for finding and extracting elements and attributes from XML documents. XQuery for XML is like SQL for databases XQuery is built on XPath expressions XQuery is supported by all the major database engines (IBM, Oracle, Microsoft, etc.)‏ Think of XQuery as SQL for a relational database for XML.

Example of XQuery Example of an XQuery expressions: <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> </bookstore> Example of an XQuery expressions: doc("books.xml")/bookstore/book/title Will return: <title lang="en">Everyday Italian</title>

The XQuery FLWOR for: Iterates through a sequence, bind variable to items let: binds a variable to a sequence where:eliminates items of the iteration order by: reorders items of the iteration return: constructs query results Example of a XQuery expression: for $x in doc("books.xml")/bookstore/book where $x/price>29 return $x/title Will return: <title lang="en">Everyday Italian</title>

Going from XML Model to Relational Model XML documents can be decomposed into a relational table. Those decomposed XML documents can be made into relational tables and published to an XML document( they might differ from the original) During the decomposing process, the XML document loses most of it structure in order to map into the relational table; not all the tags are stored in the relational tables.

Example of an XML document <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> <PROD_ID>94866</PROD_ID> <PROD_NAME>BINDER</PROD_NAME> <PRICE>7.95</PRICE> <QUANTITY>26</QUANTITY> <PROD_ID>92219</PROD_ID> <PROD_NAME>LABELS</PROD_NAME> <PRICE>12.95</PRICE> <QUANTITY>250</QUANTITY> </ORDER> XML document decomposed into a relation Order Items

Another Example..... Sales Order Items table <SalesOrder Number="123"> <OrderDate>2003-07-28</OrderDate> <CustomerNumber>456</CustomerNumber> <Item Number="1"> <PartNumber>XY-47</PartNumber> <Quantity>14</Quantity> <Price>16.80</Price> </Item> <Item Number="2"> <PartNumber>B-987</PartNumber> <Quantity>6</Quantity> <Price>2.34</Price> </SalesOrder> Items table

Hybrid DBMS There are DBMS that allow the use of both the relational model and the XML data model, a so call “Hybrid” model. An example of such a DBMS is IBMs DB2. Architecture of DB2

References (1) “Comparison of XML Model and the Relational Model.” DB2 Version 9 for Linux, UNIX, and Windows.10 April. 2007 <http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.apdv.embed.doc/doc/c0023811.htm>. (2) W3Schools. <http://www.w3schools.com/xpath/default.asp> (3) W3Schools. <http://www.w3schools.com/xquery/default.asp> (4) Coss Rafael. “DBS 9 pureXML”. IMSS_DB2pureXML_v3.ppt. (5) Coss, Rafael. “XML L2 Skills Transfer - template”. Jan 14, 2005. XML_L2~1.ppt (6) Bourret, Ronald. XML “DatabaseProducts“. Ronald Bourret Consulting, writing, and research in XML and database. March 13, 2007. <http://www.rpbourret.com/xml/XMLDatabaseProds.htm#xmlanddatabases> When thinking about designing a database thought about how you will need to store the data should come up. Should you use a database that stores data in a relational model, like we have been learning? Or should we try something different like XML? Or how about both?

(7) W3Schools. <http://www.w3schools.com/dtd/default.asp> (8)Steegmans, Bart. Bourret, Ronald. Olivier, Guvennet.” XML for DB2 Information Integration”. IBM Redbooks .<http://www.redbooks.ibm.com/redbooks/SG246994/wwhelp/wwhimpl/java/html/wwhelp.htm>