DOC PREVIEW
SJSU CS 157A - XML and The Relational Data Model

This preview shows page 1-2-3-24-25-26 out of 26 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5XML data is hierarchical XML data is self-describing XML data has inherent ordering An XML database contains collectionsSlide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26XML 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 modelWhat is XML? 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.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.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.What is an XML Database?Simply a database that stored XML DocumentsXML Model VS. Relational Model? XML data is hierarchicalXML 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 tablesRelational 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 integrityXML Model The XML Model is hierarchical format Data is represented in trees structuresThere's nodesRelationships between the nodeThe schema provides flexibilityEasily modified formatmultiple 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)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. Example of a DTD on next slide.......<?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><?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"?><!ELEMENT message (to,from,subject,text)><!ELEMENT to (#PCDATA)><!ELEMENT from (#PCDATA)><!ELEMENT subject (#PCDATA)><!ELEMENT text (#PCDATA)>Inline DTD External DTDmessage.dtdmessage.xmlmessage.xmlWhat 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 extensionExample of a XSD on next slide.......<?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>How do you access XML data?There are several languages used to access XML data from XML Documents, some are:XPathXQueryXML-QLXQLetc....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:ElementAttributeTextNamespaceProcessing-InstructionCommentDocument(root)<?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 nodeElement nodeAttribute nodeExample of an XPath expressions:/bookstore Will select the root element bookstore /bookstore/book Selects all book elements that are children of bookstoreExamples of XPathXQuery 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.)<?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/titleWill return: <title lang="en">Everyday Italian</title>Example of


View Full Document

SJSU CS 157A - XML and The Relational Data Model

Documents in this Course
SQL

SQL

18 pages

Lecture

Lecture

44 pages

Chapter 1

Chapter 1

56 pages

E-R Model

E-R Model

16 pages

Lecture

Lecture

48 pages

SQL

SQL

15 pages

SQL

SQL

26 pages

Lossless

Lossless

26 pages

SQL

SQL

16 pages

Final 3

Final 3

90 pages

Lecture 3

Lecture 3

22 pages

SQL

SQL

25 pages

Load more
Download XML and The Relational Data Model
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view XML and The Relational Data Model and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view XML and The Relational Data Model 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?