Download Querying XML Views of Relational Data

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Extensible Storage Engine wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Relational algebra wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Database wikipedia , lookup

SQL wikipedia , lookup

Functional Database Model wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Versant Object Database wikipedia , lookup

Clusterpoint wikipedia , lookup

Relational model wikipedia , lookup

Database model wikipedia , lookup

Transcript
XML Views
Advanced XML data management
El Hazoui Ilias
Supervised by: Dr. Haddouti
View Concept in Relational
Databases.
• Any relation that is not part of the logical model but
is made visible to a user as a virtual relation.
• Acts as a window through which the data from the
tables can be viewed or changed (limited).
- Purpose:
- Certain data need to be hidden from users.
- Create a personalized collection of relations that
matches a certain user’s intuition.
What is an XML view ?
XML View
? ----> XML Document
• XML View can be applied to any kind of
data source such as Relational databases.
• XML view allows us to query the database
as if it were storing XML. We query the
database by querying the XML view, to get
at the end…. An XML document.
Importance of XML Views.
• XML Data is primarily used as a common model
for heterogeneous data, since XML is becoming
the standard for data integration, and data
exchange on the internet based business
applications.
• But! Most data will continue to be stored in
relational databases. This has created the need to
publish existing business data as XML.
• providing XML views over that relational data is
one solution.
Web Services Example
Supplier provides an XML View of its Data
XQuery over Catalog
Buyer
Internet
XQuery Result
XQuery
Application Code
Convert XQuery to
SQL Query
SQL Query
XQuery Result
Application Code
Convert Relational
Data to XML
SQL Result
Relational Database
Supplier
XML View Architecture.
• A possible architecture is based on three
components:
- The data server that can be a database, an XML
repository, or any source capable of exporting XML
data.
- The View server that restructures data to construct
the view, possibly deals with access rights, and
integrates data from several sources.
- An XML view document that is handled by a
standard Web browser and interacts with view
server to obtain data.
XML View Architecture
Vie w
Specification
Data Server
Vie w
Server
XML
Repository
Vie w Docume nts
(Possibly virtual)
XML
Stylesheet
Web
Browser
Vie w
Pages
External
Application
Deriving XML Views from a
Relational Schema
- Simplest Mapping
• Root node is the database; each view and base
table is a node at the next level; each tuple in the
view/table is a node at the following level; and
finally, each attribute in each tuple is a node below
that.
• ELEMENT Database (Table)
• ELEMENT Table (Row)
• ELEMENT Row ( Attribute)
Deriving XML Views from a
Relational Schema (contd..)
Database
Relation, R1
Relation, Rn
Ri
Tuple, T1
Attribute, A1
Attribute, An
Universal View of Any Relational Data
Implementation of XML views
MIX project of San Diego Supercomputer Center and the
Database Lab at the University of California San Diego.
•
The Mediation of Information using XML
(MIX) project, is a wrapper-mediator system
which employs XML as a mean for information
modeling, as well as interchange across
heterogeneous information sources ( GIS
systems, and web sites with HTML pages).
However, this project is not optimized for
RDBMS’s.
Implementation of XML views
•
•
•
Most commercial database systems provide a
way to create materialized views of relational
data.
However, most of these systems do not support
queries over XML views.
MS SQL Server is the only one that supports
queries over XML views, but this query support
is very limited. This is because queries are
specified using XPath, which is a subset of
XQuery (XPath cannot specify joins ).
Implementation of XML views
SilkRoute
•
•
•
It is a related system that supports queries
over XML views of relational data. But, it
has many drawbacks.
It does not support XQuery.
It uses a view composition that produces
SQL queries with redundant joins.
Implementation of XML views
XPERANTO
•
•
•
XPERANTO middleware system allows existing
relational data to be viewed and queried as
XML, and which works on top of any relational
database system.
Users can define their own views on top of the
default views using XQuery.
The main advantage of this approach is that a
standard XML query language is used to create
and query views (unlike most RDBMS ).
High-Level Architecture
XQuery Query
Query Result
XPERANTO
XQuery to SQL
Converter
SQL Query
Tagger
SQL Result
Relational Database
push data- and memoryintensive computation
down to relational engine
Example Relational Data
order
id
custname
custnum
10 Smith Construction 7734
9 Western Builders
7725
item
oid
desc
cost
10 generator 8000
10 backhoe 24000
payment
oid due
amt
10 1/10/01 20000
10 6/10/01 12000
Default XML View
<db>
<order>
<row> <id>10 </id> <custname> Smith Construction </custname> … </row>
<row> <id> 9 </id> <custname>Western Builders </custname> … </row>
</order>
<item>
<row> <oid> 10 </oid> <desc> generator </desc> <cost> 8000 </cost> </row>
<row> <oid> 10 </oid> <desc> backhoe </desc> <cost> 24000 </cost> </row>
</item>
<payment>
… similar to <order> and <item>
</payment>
</db>
XML View for Partners
<order id=“10”>
<customer> Smith Construction </customer>
<items>
<item description=“generator” >
<cost> 8000 </cost>
</item>
<item description=“backhoe”>
<cost> 24000 </cost>
</item>
</items>
<payments>
<payment due=“1/10/01”>
<amount> 20000 </amount>
</payment>
<payment due=“6/10/01”>
<amount> 12000 </amount>
</payment>
</payments>
</order>
…
Creating an XPERANTO View
create view orders as (
for $order in view(“default”)/order/row
return <order id=$order/id>
<customer> $order/custname </customer>
<items>
for $item in view(“default”)/item/row
where $order/id = $item/oid
return <item description=$item/desc >
<cost> $item/cost </cost>
</item>
</items>
<payments>
for $payment in view(“default”)/item/row
where $order/id = $payment/oid
return <payment due=$payment/date>
<amount> $payment/amount </amount>
</payment>
sortby(@due)
</payments>
</order>)
Allow Partners to Query View
Get all orders of customer ‘Smith…’
for $order in view(“orders”)
where $order/customer/text() like ‘Smith%’
return $order
Conclusion
• XML Views permits a flexible, efficient XML
representation of relational data.
• An XML View can select data from disparate tables
and join them together into one XML document.
• XPERANTO allows users to publish relational data
as XML
– Using a high-level XML query language
– Eliminating the need for application code
Conclusion
• XML Views permits a flexible, efficient XML
representation of relational data.
• An XML View can select data from disparate tables
and join them together into one XML document.
• XPERANTO allows users to publish relational data
as XML
– Using a high-level XML query language
– Eliminating the need for application code
Conclusion
• XPERANTO works on top of any relational
database system
• Has a very good performance result, for example
the query compilation time is in the order of
milliseconds (200 ms for query over 12 tables).
• But, researches are still carried out to define a
standard of XML views that will better serve the
XML community.
Your questions are more than
welcome.