Title: Ling Wang, Mukesh Mulchandani, Elke A. Rundensteiner
1Updating XQuery Views Published over Relational
Data A Round-trip Case Study
Ling Wang, Mukesh Mulchandani, Elke A.
Rundensteiner Database Research Group Computer
Science Department Worcester Polytechnic Institute
2Introduction
- XML is standard for exchanging data between web
applications - But RDBMS is mature data management technology
- - Reliable persistent storage
- - Mature query optimization
- XML Management Systems using relational
technology - - SilkRoute (ATT), XPERANTO (IBM), RAINBOW
(WPI) - - Features
- 1. provide reliable persistent storage
- 2. support XML view mechanism for XML data
publishing - 3. support queries over XML views
3Introduction
- View to be useful, retrieval and update
operations needed. - Query on the virtual views
- - Retrieval mapping
- Query on View ? Query on relational database
- - Yes! The mapping always exists.
- Easy to handle.
- Update on the virtual views
- - Update mapping
- Update on View ? Update on relational database.
- - Two possibilities
- 1. Not exists.
- 2 Exist, but not unique.
- Harder to handle.
- Updates is needed for viable XML management
system.
4A Subproblem --- Round-trip XML View Update
1. What is RXU ? - Assume a two-way
mapping XML schema document
Structured Relational Database - How to
translate update on view into updates on
relational structured database.
General XML view update problem
Round-trip XML view update problem (RXU)
5Why RXU ?
- Common and useful case! Many XML data systems
use relational storage. - Features of RXU
- - A structured database captures enough
information to reconstruct XML schema data. - - View is an inverse image of original XML
document schema. - Influence on update
- View updates in RXU are always translatable! (
Provable )
6RXU --- Old Problem with New Challenges
- View update problem in relational databases
- - Is a given view updatable? - What is a
correct translation? - How to eliminate
ambiguity in translation? - XML view update comes with new challenges
- - Handle two mappings
- Data model mapping --- XML vs.
Relational Query language mapping --- XQuery
vs. SQL - - Ensure consistency between
- original XML schema ? Relational schema ? XML
view schema
7Example XML Document Schema
ltbibgt ltbookgt lttitlegtTCP/IP Illustratedlt/titlegt
ltauthorgt ltanamegtW. Stevenslt/anamegt lt/author
gt lt/bookgt ltbookgt lttitlegt Data on the Web
lt/titlegt ltauthorgt ltanamegtSerge
Abiteboullt/anamegt ltanamegtPeter
Bunemanlt/anamegt lt/authorgt lt/bookgt lt/bibgt
ltxsschema xmlnsxs"http//www.w3.org/2001/XMLSch
emagt ltxselementname"bib"gt ltxscomplexTypegt
ltxssequencegt ltxselementname"book"
maxOccurs"unbounded"gt ltxscomplexTypegt
ltxssequencegt ltxselementname"title"
type"xsstring" nillable"false"/gt ltxsele
mentname"author"gt ltxscomplexTypegt
ltxssequencegt ltxselementname"aname"
type"xsstring" maxOccurs"unbound
ed"/gt lt/xssequencegt lt/xscomplex
Typegt lt/xselementgt lt/xscomplexTypegt
lt/xselementgt lt/xssequencegt lt/xscomplex
Typegt lt/xselementgt lt/xsschemagt
Example XML Schema
Example XML Document
8Example Structured Database
author
book
FOREIGNKEY author (bookid) REFERENCES book
(bookid)
Structured Relational Database using Inlining
Loading
A structured database capture enough
information to reconstruct XML schema data.
9Example XQuery View
ltDBgt ltbookgt ltrowgt ltbookidgt001lt/bookidgt ltt
itlegtTCP/IP Illustratedlt/titlegt lt/rowgt lt/bookgt
ltauthorgt ltrowgt ltbookidgt001lt/bookidgt ltaut
horidgt001lt/authoridgt ltanamegtW.
Stevenslt/anamegt lt/rowgt lt/authorgt lt/DBgt
ltbibgt FOR book in document("default.xml")/book/ro
w RETURN ltbookgt lttitlegtbook/title/text()lt/
titlegt, ltauthorgt FOR author in
document("default.xml")/author/row WHERE
book/bookid author/bookid RETURN
ltanamegtauthor/aname/text()lt/anamegt
lt/authorgt lt/bookgt lt/bibgt
Default XML view
Extraction query
A one-to-one mapping to relational database
Construct an XML view with same schema data as
original XML schema document
10How to get RXU ?
- Requirements 1. Relational database is
constructed by lossless constraints data
loading. 2. View is constructed by extraction
query --- data schema inverse. 3. View update
is valid --- satisfy all constraints of view
schema. - Not all loading strategies satisfy RXU
requirements! - Characterize the loading - Data loading -
Constraints loading
11RXU Loading Characterization
- Lossless data loading
- Def Given an XML document Dx, a loading L
generates a relational database instance Dr,
denoted by LDx ?Dr, L is a lossless data loading
iff ?L such that L Dr ? Dx holds true. - Intuition - All leaves in XML tree captured.-
Data inverse-able.
12RXU Loading Characterization
- Lossless constraint loading
- Def Given an XML schema Sx, a loading L
generates a structured database with schema Sr,
denoted by L Sx ? Sr. L is a lossless constraint
loading iff exists extraction query Q generating
an XML view with schema Sv, such that SvSx
holds. - Intuition - The extracted XML view schema
includes all constraints of original XML schema.
- The set of valid update operations are equal
Uv Ux. Uv view update set Ux XML
document update set
13RXU Loading Characterization
- RXU requires a lossless loading
- Lossless data loading Lossless constraints
loading
Lossless loading
14Updatability of RXU
- Translation criteria
- Correctness Criteria
- ( Rectangle rules )
- Simplicity Criteria
- (1) One step change
- (2) Minimal changes
- (3) Replacement cannot be simplified
- (4) No insert-delete pairs.
- Intuition Correctness criteria used to decide
the view updatability. - Simplicity criteria used to construct optimal
translation plan.
True - u is translatable - V is updatable for
given u
V
u(V)
u
DEFv
DEFv
In RXU DEFv Extraction Query
S
U(V)
U
- Observation about Updatability of RXU
- Within the RXU, given an XQuery view definition
DEFv defined over the relational state s, ?u?Uv ,
u is translatable.
15Updatability of RXU
- Complementary Theory
- F Bancilhon and N. Spyratos, Update Semantics of
Relational Views, - ACM Transactions on Database Systems, 1984
- Basic Definition
- Def 1 Let f,g be two mappings. We say that f is
greater than g, denoted by f ?g, iff ?s?S, ?s?S,
f(s)f(s) gt g(s)g(s). - Intuition Whenever we know f(s), we can
compute g(s). - Def 2 Let f,g be two mappings. We say that f
and g are equivalent, denoted by f ? g, iff f ? g
and g ? f. - Def 3 Let f,g be two mappings. The product of f
and g, denoted by f?g, is defined by f?g(s)
(f(s),g(s)), ?s?S. - Intuition f?g adds to f the information in
g. - Def 4 Let f,g be two mappings. A view g is
called a complement of f, iff f?g ? 1. - Note identity mapping 1, Constant mapping
0
16Updatability of RXU
- Complementary Theory
- Given a complement g of f and a view update u?Uv
, u is g-translatable iff ?s?S, ?s?S so that
f(s)uf(s) and g(s)g(s). - Intuition Given a complement g of the view
f and a view update u, the translation of u that
leaves g invariant is the desired translation.
17Updatability of RXU - Proof
- Updatability of RXU
- Within the RXU, given an XQuery view definition f
defined over the relational state s, ? u?Uv , u
is translatable. - Idea
- (1) In RXU, ?f, f ? 1. (f is the extraction
query) - f ? 1 because ?s?S, ?s?S, f(s)f(s) gt
1(s)1(s). 1? f always holds. - (2) 0 is complement of 1 ? 0 is the complement
view of f. - (3) ? u?Uv , let f(s) uf(s), 0(s) 0(s)
always holds. - (4) By complementary theory, u is always
translatable. -
18Update System in Rainbow --- Rainfall
View Query
User Query
Result XML
Legend
XQuery Parser
Parsed Tree
Information Collecter
View Analyzer
Valid Update Checker
XAT Generator
View Query
Process Step
XAT
XAT
XAT
XQuery View Manager
View Composer
Meta -Data
Materialized data
XAT
XAT Rewriter
XAT
XAT
View Query XAT
Update Decomposer
Update Translator
Update Propagator
Process Flow
SQL Generator
Data Flow
Rainbow Query Engine
XAT Executor
Multiple SQL updates
Rainfall
SQL
RDBMS
RDBMS
Oracle
SQL-Server
Sybase
DB2
19Update XQuery Grammar
- Tatarinov Ives, Alon Halevy and Daniel Weld,
Updating XML, SIGMOD 2001
- FOR binding1 IN Xpath-expr,...
- LET binding Xpath-expr, ...
- WHERE predicate1, ...
- updateOp, ...
-
- Where updateOp is defined in EBNF as
-
- UPDATE binding subOp , subOp and subOp
is -
- DELETE child
- RENAME child To new_name
- INSERT ( bind BEFORE AFTER child
- new_attribute(name, value)
- new_ref(name, value)
- content BEFORE AFTER child )
- REPLACE child WITH ( new_attribute(name,
value) - new_ref(name, value)
- content )
- FOR sub_binding IN Xpath-subexpr, ...
20Decomposition-based Update Translation Solution
RDB
author
book
FOREIGNKEY author (bookid) REFERENCES book
(bookid)
View Query
XML View
ltbibgt ltbookgt lttitlegtTCP/IP Illustratedlt/titlegt
ltauthorgt ltanamegtW. Stevenslt/anamegt lt/author
gt lt/bookgt ltbookgt lttitlegt Data on the Web
lt/titlegt ltauthorgt ltanamegtSerge
Abiteboullt/anamegt ltanamegtPeter
Bunemanlt/anamegt lt/authorgt lt/bookgt lt/bibgt
ltbibgt FOR book IN document("default.xml")/book/ro
w RETURN ltbookgt lttitlegtbook/title/text()lt/
titlegt, ltauthorgt FOR author IN
document("default.xml")/author/row WHERE
book/bookid author/bookid RETURN
ltanamegtauthor/aname/text()lt/anamegt
lt/authorgt lt/bookgt lt/bibgt
21Update Decomposition
Example Translation of Delete Request
DELETE FROM book WHERE book.ROWID IN (
SELECT DISTINCT book.ROWID FROM book WHERE
(book.title TCP/IP Illustrated ) )
DELETE FROM author WHERE author.ROWID IN (
SELECT DISTINCT author.ROWID FROM book,author
WHERE (book.title TCP/IP Illustrated ) AND
(book.bookid author.bookid) )
User Update Query
FOR root IN document("View.xml"), book IN
root/bookWHERE book/title/text() " TCP/IP
Illustrated " UPDATE root DELETE book
Update Propagation Translation
DELETE FROM book WHERE book.ROWID IN (
SELECT DISTINCT book.ROWID FROM book
WHERE (book.title TCP/IP Illustrated ) )
View Analyze
CREATE OR REPLACE TRIGGER DeleteBOOK_To_Update_AUT
HOR BEFORE DELETE ON BOOK FOR EACH ROW BEGIN
DELETE FROM AUTHOR WHERE BOOKID
OLD.BOOKID END
Updated RDB
book
author
22Update Decomposition
Example Translation of Insert Request
INSERT INTO book ( bookid, title) Values
('003', 'Languages and Machines')
INSERT INTO author ( bookid, authorid, aname )
Values ('003', '001', 'Thomas A. Sudkamp')
User Update Query
FOR root IN document("view.xml") UPDATE root
INSERT ltbookgt lttitlegt"Languages and
Machines"lt/titlegt, ltauthorgt ltanamegt"Tho
mas A. Sudkamp"lt/anamegt lt/authorgt lt/bookgt
Update Propagation Translation
Same as above.
Updated RDB
book
View Analyze
CREATE OR REPLACE TRIGGER DeleteBOOK_To_Update_AUT
HOR BEFORE DELETE ON BOOK FOR EACH ROW BEGIN
DELETE FROM AUTHOR WHERE BOOKID
OLD.BOOKID END
author
23Experimental Setup
- Test system
- Intel(R) Celeron(TM) 733MHz processor, 384M
memory - Windows2000, Java 1.3.0\_01
- Database
- Oracle 8i under SUSE LINUX
- Factors considered
- - Type of update operation
- - Loading strategy used to build relational
database - - Size of XML document
24Experimental Evaluation
Update Translation vs. Reloading
25Experimental Evaluation
Performance comparison for different update
types File-size 800 elements/file
26Related Work
- Umeshwar Dayal, Philip A. Bernstein, On the
Updatability of Relational Views, IEEE 1978. - First work, describes criteria of correct update
translation. - F Bancilhon and N. Spyratos, Update Semantics of
Relational Views, ACM Transactions on Database
Systems, 1984 - Complementary theory to eliminate ambiguity in
update translation. - A. M. Keller, Barsalou, Siambela and Wiederhold,
Updating Relational Databases through
Object-Based Views, SIGMOD 1991 - View update problem in object-base views.
- Tatarinov Ives, Alon Halevy and Daniel Weld,
Updating XML, SIGMOD 2001 - XQuery update extension, XML view update
performance
27Conclusions
- Characterize Round-trip XQuery View Update
Problem (RXU). - Study the updatability of RXU.
- Decomposition-based update translation solution.
- Prototype system --- Rainfall
- Performance study
28Future Work
- Order sensitive view update
- Batch update processing
- Performance in update translation
- - Choose triggers for query plan optimization
- - Use index speeding up path expression
evaluation - - Use materialized view to improve performance
- Schema changes
- http//davis.wpi.edu/dsrg/rainbow/