Databases
YoonJoon Lee (李 潤 俊)韓國科學技術院
Contents
• What is XML?
• XML Data vs Documents
• Store and retrIEve XML in RDB
• GML
What is XML?
– A markup language that you can use to create your own tags
– Created by W3C to overcome the limitations of Html
– Based on SGML(Standard Generalized Markup Language – “Sounds great, maybe later), used in publishing industry
– Designed with the Web in mind
Origins of XML
– In 1996, Jon Bosak convinced that W3C to let him form a committee on using SGML on the Web.
– November, the committee has created the beginning of a simplifIEd form of SGML, this was XML.
– In March 1997, Bosak released a paper “XML, Java and the Future of the Web.”
– SGML was created for general document structuring, Html as an application SGML for Web document, XML is a simplification of SGML for general Web use.
A Sample XML document
<address>
<name>
<title>Mrs.</title>
<first-name>Mary</first-name>
<last-name>McGoon</last-name>
</name>
<street>1401 Main Street</street>
<city state=“NC”>Anytown</city>
<postal-code>34829</postal-code>
</address>
Tags, elements and attributes
DTD (1/2)
– Document type definition
– Extensible in XML, a dialect of XML
• RDF, HL7 SGML/XML, MathML, XML/EDI, FDX
– Describes what tags the markup language has, what tags’ attribute may be, and how they may be combined.
– SpecifIEs very clearly what information may or may not be included in markup language.
– DTD syntax is different from ordinary XML syntax.
DTD (2/2)
<!-- address.dtd -->
<!ELEMENT address (name, street, city, state, postal-code)>
<!ELEMENT name (title? first-name, last-name)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT first-name (#PCDATA)>
<!ELEMENT last-name (#PCDATA)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT state (#PCDATA)>
<!ELEMENT postal-code (#PCDATA)>
Is XML a DB?
• “collection of data”
• Advantages: self-describing, portable, data in tree or graph structure
• Disadvantages: verbose, slow Access
+ storage, schemas, query languages, programming interfaces, …
- efficIEnt storage, indexes, security, transactions and data integrity, multi-user Access. Trigger querIEs across multiple documents, …
Why DB?
• Want to expose legacy data
• Looking for a place to store web pages
• Database used by an e-commerce application in which XML is used as a data transfer
• Interested in Data or Documents
Data vs. Documents
• Used simply as a data transport between the database and a application?
• Integral use as in the case of XHtml and DocBook documents?
Data-Centric Documents (1/2)
• For Machine consumption
Ex) sales orders, flight schedules, …
• Fairly regular structure, fine-grained data and little or no mixed content, no significant order in sibling
Data-Centric Documents (2/2)
<FlightInfo>
<Airline>ABC Airways</Airline> provides <Count>three</Count> non-stop flights daily from <Origin>Dallas</Origin> to <Destination>Fort Worth</Destination>. Departure times are <Departure>09:15</Departure>, <Departure>11:15</Departure>, and <Departure>13:15</Departure>. Arrival times are minutes later.
</FlightInfo>
<Flights>
<Airline>ABC Airways</Airline>
<Origin>Dallas</Origin>
<Destination>Fort Worth</Destination>
<Flight>
<Departure>09:15</Departure>
<Arrival>09:16</Arrival>
</Flight>
<Flight>
<Departure>11:15</Departure>
<Arrival>11:16</Arrival>
</Flight>
<Flight>
<Departure>13:15</Departure>
<Arrival>13:16</Arrival>
</Flight>
</Flights>
Document-Centric Documents (1/2)
• For human consumption
Ex) books, email, advertisement, …
• Less regular or irregular structure, larger grained data, lots of mixed contents, almost significant order in sibling
Document-Centric Documents (2/2)
<Product>
<Intro>
The <ProductName>Turkey Wrench</ProductName> from <Developer>Full Fabrication Labs, Inc.</Developer> is <Summary>like a monkey wrench, but not as big.</Summary>
</Intro>
<Description>
<Para>The turkey wrench, which comes in <i>both right- and left- handed versions (skyhook optional)</i>, is made of the <b>finest stainless steel</b>. The Readi-grip rubberized handle quickly adapts to your hands, even in the greasiest situations. Adjustment is possible through a varIEty of custom dials.</Para>
<Para>You can:</Para>
<List>
<Item><Link URL="Order.Html">Order your own turkey wrench</Link></Item>
<Item><Link URL="Wrenches.htm">Read more about wrenches</Link></Item>
<Item><Link URL="Catalog.zip">Download the catalog</Link></Item>
</List>
<Para>The turkey wrench costs <b>just $19.99</b> and, if you order now, comes with a <b>hand-crafted shrimp hammer</b> as a bonus gift.</Para>
</Description>
</Product>
Store & RetrIEve XML
• File
• RDBMS
• OODBMS
• Special purpose systems for semi-structure data
Storing XML Data in RDBMSs
+ RDBMS: a matured technology
+ RDBMS widely available
+ Less investment to adopt the new technology
+ Easy to be integrated with other existing applications
- Impedance mismatch
– Two level nature of relational schema (tuples and attributes) vs. arbitrary nesting of XML DTD
– Flat structure vs. recursion
– Structure-based and content-based query
Storing XML Data in RDBMSs: Architecture
Storing XML Data in RDBMSs: Issues
• Schema/Data mapping:
– Automate storage of XML in RDBMS
• Query mapping:
– Provide XML vIEws of relational sources
• Result construction:
– Export existing data as XML
XML-Relational Mapping
• Model mapping
– Database schemas represent constructs of the XML document model.
• DTD Independent
[Florescu & Kossmann 99, Yoshikawa, et. al. TOIT01]
• Structure mapping
– Database schemas represent the logical structure of target XML documents
• DTD Dependent
[Shanmugasundaram et. al. VDLB 99]
Model Mapping: Edge, XRel, and XParent
• Edge: a single large table for handing any structures.
• XRel and XParent: four tables
– The structure handling:
• XRel: The structure is coded in the data using region codes (start, end).
• XParent: The structure in a separated “Parent” table (parent-Id, child-Id). (Can be extended to support ancestors in an additional table)
– Partitioning:
• XRel: Partition Edge by content (Element, Data, Attribute)
• XParent: Partition Edge by content and “structure vs non-structure)
– Label-path handling: explicitly as data
Edge (1/3)
• Mapping edges – Edge approach
Edge (2/3)
Edge (3/3)
XRel (1/6)
XRel (2/6)
XRel (3/6)
XRel (4/6)
XRel (5/6)
XRel (6/6)
XParent (1/4)
XParent (2/4)
XParent (3/4)
XParent (4/4)
GML (1/2)
• GML (Geographic Markup Language) = GIS + XML
• GML is an XML-based language for encoding geographic information in order to be stored and transported over the Internet, developed by the OpenGIS Consortium
• GML defines both the geometry and propertIEs of objects that comprise geographic information
GML (2/2)
• GML is a practical application for transferring cartographic information over the Web
• GML allows the data to be controlled on the browser end by the user who receives geometrIEs and geographic features and customizes how the data is to be displayed, instead of transmitting a GIF or JPG map
• Geographic data in GML can be sent to any device with an XML interface
References
• D. Florescu, D. Kossman, Storing and Querying XML Data using an RDBMS. IEEE Data Engineering Bulletin 22(3), 1999
• M. Yoshikawa et al., XRel: A Path-Based Approach to Storage and RetrIEval of XML Documents Using Relational Databases, ACM Trans. on Internet Technology, Vol. 1, No. 1, pp 110-141, 2001
• H. Jiang et al., XParent: An EfficIEnt RDBMS-Based XML Database System, In Proc. of ICDE, 2002
• H. Jiang et al., Path Materialization Revisited: An EfficIEnt Storage Model for XML Data, In Proc. of AICE, 2000
• about GML
– http://www.opengis.org
– http://www.isotc211.org
– http://www.w3c.org
– http://gml4j.sourceforge.Net
– http://www.expway.Net
– http://www.galDOSinc.com
Thanks for your attention!
Any Questions?