160 likes | 252 Views
SilkRoute: A Framework for Publishing Relational Data in XML. Mary Fernández , AT&T Labs - Research Dan Suciu, Univ. of Washington Yada Kadiyska, Univ. of Washington Atsuyuki Morishima, Univ. of Tsukuba Wang-Chiew Tan, Univ. of Pennsylvania. XML-Relational Middleware.
E N D
SilkRoute: A Framework for Publishing Relational Data in XML Mary Fernández, AT&T Labs - Research Dan Suciu, Univ. of Washington Yada Kadiyska, Univ. of Washington Atsuyuki Morishima, Univ. of Tsukuba Wang-Chiew Tan, Univ. of Pennsylvania
XML-Relational Middleware • XML: Standard, flexible syntax for exchanging data • Lingua franca of B2B Applications • Industry defines common XML vocabulary • Document Type Descriptions (DTDs) or XML Schema • Contract between data producers & consumers • Reflects application domain • XML-Relational Middleware • Key business data in RDBMS • Glue between existing business data & application • Characteristics: General, dynamic, efficient • SilkRoute : A Reference Framework
XML Data Management API or Query Legacy Database XML XML XML Persistent Database XML Producer XML Consumer XML Documents & Schemas Publish XML XML Interfaces Store XML
Clothing Supplier & Reseller • Shared XML Schema element supplier { element company, element product* } element company { xs:string } element product { element name, element category, element retail, element sale?, element reports* } element name { xs:string } element category { xs:string } element retail { attribute cur { xs:string }, xs:float } element sale { xs:float } <supplier> <company>ACME Clothing</company> <product> <name>Suede jacket</name> <category>outerwear</category> <retail cur=“USD”>325.00</retail> <sale cur=“USD”>225.00</sale> </product> <product> <name>Rain boots</name> <category>outerwear</category> <retail cur=“USD”>45.00</retail> <sale cur=“USD”>22.50</sale> <report code=“defective”>leaks in heel</sale> <report code=“defective”>heel separates</sale> </product> </supplier>
Viewing and Querying XML Application Query ? ? • Most data in relational database • Suppliers’ goal: Define XML view of data • General: support many XML Schemas • Efficient: leverage relational database Public Query = ( ) ? Supplier Database Application
Viewing and Querying XML ? ° ? = ? ? ? ? • Brokers’ goal: Uniform access Dynamic: Access up-to-date, minimal result = ( ) Supplier database Application ) ( =
SilkRoute Framework • General, declarative view-definition language • Public Query in XQuery Maps relational data to public XML view + Support many output XML Schemas • Dynamic querying of XML views • Application Query in XQuery Maps public XML data to application’s view • Query composition algorithm + Underlying storage should be transparent to user + Access up-to-date, minimal result • Efficient use of relational engine • Query decomposition algorithm Selects query execution plan (one or more SQL queries) Uses relational engine’s cost estimates to guide search + Leverage power of relational query engine
Canonical XML View <Clothing> <Tuple> <pid>001</pid> <item>Suede jacket</item> <category>outerwear</category> <description>Hip length</description> <price>325.00</price> <cost>175.00</cost> </Tuple> <Tuple> <pid>002</pid> <item>Rain boots</item> <category>outerwear</category> <description>Ankle height</description> <price>45.00</price> <cost>19.99</cost> </Tuple> </Clothing> Clothing(pid, item, category, description, price, cost) : { <001, “Suede Jacket”, “outerwear”,”Hip length”, 325.00, 175.00>, <002, “Rain boots”, “outerwear”, “Ankle height”, 45.00, 19.99> } Discount(pid, discount) : { <001, 0.70>, <002, 0.50> } • Oracle 9i XSQL Canonical XML View Use XSLT (out of engine) to transform canonical XML
Canonical & Public Views <supplier> <company>ACME Clothing</company> <product> <name>Suede jacket</name> <category>outerwear</category> <retail cur=“USD”>325.00</retail> <sale cur=“USD”>225.00</sale> </product> <product> <name>Rain boots</name> <category>outerwear</category> <retail cur=“USD”>45.00</retail> <sale cur=“USD”>22.50</sale> <report code=“defective”>leaks in heel</sale> <report code=“defective”>heel separates</sale> </product> </supplier> <Clothing> <Tuple> <pid>001</pid> <item>Suede jacket</item> <category>outerwear</category> <description>Hip length</description> <price>325.00</price> <cost>175.00</cost> </Tuple> <Tuple> <pid>002</pid> <item>Rain boots</item> <category>outerwear</category> <description>Ankle height</description> <price>45.00</price> <cost>19.99</cost> </Tuple> </Clothing>
XQuery • Strongly typed, functional XML query language • Large-scale database access • Must guarantee safety/correctness of operations on data • Compositional: XML to XML • Q1(Q2(D)) = (Q1 o Q2)(D) • XQuery 1.0 = XPath 2.0 (path, arithmetic, logical expressions) + for-let-where-orderby-return (FLWOR) XML construction + User-defined (recursive) functions + Strong typing
Public View Query ? • Public view query expressed in XQuery • Includes all XQuery expressions Except recursive functions, features that depend on document order <supplier><company>ACME Clothing</company> { for $c in $CanonicalView/Clothing/Tuple where $c/category = “outerwear” return <product> <name>{ data($c/item) }</name> <category>{ data($c/category) }</category> <retail cur=“USD”>{ data($c/price) }</retail> </product> { for $d in $CanonicalView/Discount/Tuple where $d/pid = $c/pid return <sale cur=“USD”>{ $d/discount * $c/price } </sale> } } </supplier> • Type checking guarantees view conforms to public schema
Application Query ? • Application query expressed in XQuery for $s in $PublicView/supplier return <supplier> <name>{ data($s/name) } </name> <discounted> { for $p in $s/product where $p/sale < 0.5 * $p/retail return <product>{ data($p/name) }</product> } </discounted> </supplier> • Type checking guarantees application query correct w.r.t. public schema
SilkRoute Architecture ? ? ? ? ? ? Internet/Intranet SilkRoute Relational Engine XML Generator Application View Forest Composer View Forest Decomposer • All modules process view forests Representation of all views: canonical, public, application Maps relational data to XML document
Query Decomposition ? ? for$c in $CanonicalView/Clothing/Tuple where $c/category = “outerwear” return <product> <name>{ data($c/item) }</name> <category>{ data($c/category) }</> <retail>{ data($c/price) }</retail> </product> <product> <name>item</name> <category>category</category> <retail>price</retail> </product> SELECT $c.pid as pid, $c.item as item, $c.category as category, $c.price as price FROMClothing $c WHERE $c.category = “outerwear” • View query may decompose into multiple SQL queries • Use greedy algorithm (with help from RDBMS) to choose decomposition
Related Systems • Commercial Systems • Oracle 9i – canonical mapping • IBM DB2 XML Extender – annotated schema • Microsoft SQL Server – universal relation, annotated schema (To date), none support full XQuery SQL Server supports XPath • (Quasi) Research Systems • Xperanto (IBM Almaden) – now a product • Rolex, PRATA (Bell Labs)
Summary • XML Publishing Systems • Workhorses of B2B applications • Key characteristics: General, dynamic, efficient • Commercial Systems • Oracle, IBM DB2, Microsoft SQL Server • Some, but not all, of key characteristics • SilkRoute : A Reference Framework • General, declarative mappings from relations to XML • Query composition & decomposition • Establishes link between XQuery & SQL • Prototype (re-)implementation (JDBC-compliant database)