1 / 59

Ling Wang, Mukesh Mulchandani Advisor: Elke A. Rundensteiner Co-Advisor: Kathi Fisler

Ling Wang, Mukesh Mulchandani Advisor: Elke A. Rundensteiner Co-Advisor: Kathi Fisler. Updating XML Views over Relational Data. Outline. Motivation (Why?) Update Extension for XQuery Update Mapping - Correct Translatability - Complete Update - Partial Update

mariasmith
Download Presentation

Ling Wang, Mukesh Mulchandani Advisor: Elke A. Rundensteiner Co-Advisor: Kathi Fisler

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ling Wang, Mukesh MulchandaniAdvisor: Elke A. Rundensteiner Co-Advisor: Kathi Fisler Updating XML Views over Relational Data November 14, 2002

  2. Outline • Motivation (Why?) • Update Extension for XQuery • Update Mapping • - Correct Translatability • - Complete Update • - Partial Update • Update Extension to Rainbow System • Related Work November 14, 2002

  3. Motivation (Why?) • XML is here to stay … • - Universal representation of data • Standard for information exchange over internet • But RDBMS is mature • - Mature query optimization techniques • High query performance • Research Topic on dealing with XML with relational technology: • - Publishing XML over relational database: • SilkRoute, XPERANTO (IBM), RAINBOW • - Storing XML into RDBs • From XML Schema to Relations: A Cost-Based Approach to XML Storage (Bell Lab), RAINBOW November 14, 2002

  4. Updating XML • Sharing data from XML Repositories and traditional RD: • - Single, Unified query-able Model • - XML views + XML query language (XQuery) • XML as a full-featured data exchange format … • Support Update features • Content update + Schema update • Our Work will focus on: • Content updates • Update XML View over Relational Storage (Rainbow) November 14, 2002

  5. What should we do? • Expressing updates in XML query language syntax • - Extension to XML query language (Xquery) • - Extension to XML query Parser to support Update features XML Update Query • Update RD through XML View • - Mapping strategy to keep consistency • - Translate XML View Updates into Relation Table Updates • - Hard question … • not always exist • not always unique • no answer, no sure answer XMLView Mapping Query SQL Update RDBMS RDBMS November 14, 2002

  6. Where we are • Motivation (Why?) • Update Extension for XQuery • Update Mapping • - Correct Translatability • - Complete Update • - Partial Update • Update Extension to Rainbow System • Related Work November 14, 2002

  7. XQuery Update Grammar • A FLWU Expression FOR $binding1 INXpath-expr,….. LET $binding := Xpath-expr,… WHEREpredicate1,….. updateOp,…… Where updateOp is defined as : UPDATE $binding {subOp {, subOp}* } and subOp is : DELETE $child | RENAME $childTo new_name | INSERT ( $bind [BEFORE | AFTER $child] | new_attribute(name, value) | new_ref(name, value) | content [BEFORE | AFTER $child] ) | REPLACE $childWITH ( new_attribute(name, value) | new_ref(name, value) | content ) | FOR $sub_bindingINXpath-subexpr,….. WHEREpredicate1,………. updateOp. November 14, 2002

  8. Example of XML document & XQuery (1) <DB> <Book> <row> <Bookid> 1 </Bookid> <Title> Data Structures in C++ </Title> <Year> 2000 </Year> </row> <row> … </row> </Book> <Author> <row> <first> Michael </first> <last> Savitch </last> <bookid> 1 </bookid> </row> <row> … </row> </Author> <Publisher> <row> <Name> McHill </Name> <Address> NY,USA </Address> <Pubid> 1 </Pubid> </row> <row> … </row> </Publisher> </DB> Relational Database: Book Author Publisher November 14, 2002

  9. Example of XML document & Xquery (2) Mapping Query XML View: <Bookview> FOR$booktuple IN document(“Default.xml”)/book/row $authortuple IN document(“Default.xml”)/author/row WHERE $booktuple/Bookid =$authortuple/Bookid RETURN <Book> $booktuple/BookId $booktuple/Title $booktuple/Year <Author> $authortuple/first $authortuple/last </Author> </Book> </Bookview> <Bookview> <Book> <BookId>1</BookId> <Title> Data Structure in C++ </Title> <Year>2000</Year> <Author> <first>Michael</first> <last>Savitch</last> </Author> </Book> <Book> <BookId>2</BookId> <Title> JAVA 2 Reference </Title> <Year>1998</Year> <Author> <first> Peter</first> <last> Naughton</last> </Author> </Book> </Bookview> November 14, 2002

  10. Example of XML document & Xquery (3) User Update Expected Effect FOR $root IN document(“bookview.xml”) $book IN $root/book [first = “Michael”][last = “Savitch”] UPDATE $root{ DELETE $book } </Bookview> <Book> <BookId>2</BookId> <Title> JAVA 2 Reference </Title> <Year>1998</Year> <Author> <first> Peter</first> <last> Naughton</last> </Author> </Book> </Bookview> November 14, 2002

  11. Where we are • Motivation (Why?) • Update Extension for XQuery • Update Mapping • - Correct Translatability • - Complete Update • - Partial Update • Update Extension to Rainbow System • Related Work November 14, 2002

  12. Correct Translatability (1) • Background Material: • Philip A. Bernstein, On the Updatability of Relational Views, IEEE 1978 • Correctness Criteria for Update Translating: • Update Translatable = Unique set of updates U • + No extraneous updates in U • + No side effects on View V • + preserve Semantic consistency November 14, 2002

  13. Correct Translatability (2) • Extraneous updates • Produce same effect in View with or without extraneous update V: Insert (Dannel, CS) Insert ( Dannel, CS, 22 ) Insert ( Dannel, CS, - ) RD: • No Side effects on View • Only desired update is performed on the view V: Side effect on View RD: November 14, 2002

  14. Correct Translatability (3) • Semantic Consistency • Preserve Constraints, Key, Foreign Key, Not null ... • Uniqueness • -Several Mapping could exist • - Random choice is un-acceptable • - Use Constraints for unambiguous • - No Constraints: Null value • eg: Insert ( Dannel, CS, - ) November 14, 2002

  15. Notation ---- Relation, Key, Non-Key • Relation R is an ordered set of attributes S=(A1,A2,…,Ai). • For any relation R, the set of attributes S is partitioned into two subsets: • K---- the ruling part (Key) of relation schema. • NK---- the dependent part ( non key ) of relation schema Book S = (BookId, Title, Year) K: BookId, ISBN NK: Title, Year November 14, 2002

  16. Notation ---- Connection • Connection is a relationship between a pair of relations. • Two relations R1 and R2 are connected by two subsets of attributes X1 and X2, which have identical number of attributes and domains. R1 and R2 are connected through the ordered pair (X1,X2) Book S1 = (BookId, Title, Year) K1 = (BookId) X1 = BookId S2 = (BookNo, First, Last, Birthday) K2 = (BookNo, Birthday) X2 = BookNo Book and Author connected through (X1,X2) Author November 14, 2002

  17. Notation ---- comparison R2 R! * R2 R! R2 R! November 14, 2002

  18. Graph theory for Relational Database Possible Relation: Book * * Example: Author Book Publisher Book (Book.Publisher, Author.PublisherId) (Book.BookId, Author.BookNo) * Author Publisher November 14, 2002

  19. Notation ---- Pivot relation • Pivot Relation (R1) • - Core Component of View, Each XML View is anchored on it • - K(V) = K(R1) , pivot relation has the same key with XML view. • Note: Could be several pivot relation candidate. Book <Bookview> <Book> <BookId> 1 </BookId> <Title> Data Structure in C++ </Title> <Year>2000</Year> <Author> <first>Michael</first> <last>Savitch</last> </Author> </Book> <Book> … </Book> </Bookview> Author Book is Pivot Relation for BookView If: BookId as key of BookView November 14, 2002

  20. Notation ---- Dependency island, Referencing Peninsula • Dependency island of view • Maximal sub-tree • All directed pathsbeginning at root relation contain exclusively ownershipand subset connections • Referencing Peninsula • - A relation Rj • - Directly connected to any relation of dependency island Rk via Reference connection Rk<--Rj November 14, 2002

  21. Notation ---- Dependency island, Referencing Peninsula (Example) * - Dependency Island Book - Referencing peninsula BookId PublisherId BookId Publisher Chapter Author StateID BookId AuthorId * PhoneBook State Review November 14, 2002

  22. Where we are • Motivation (Why?) • Update Extension for XQuery • Update Mapping • - Correct Translatability • - Complete Update • - Partial Update • Update Extension to Rainbow System • Related Work November 14, 2002

  23. Complete Update • Background Material: • A. M. Keller, Updating Relationsl Databases through Object-Based Views, SIGMOD 1991 • What is Complete Update ? • - Complete Insertion / Deletion • Inserting / Deleting a fully specified element. • - Complete Replacement. • Complete deletion + Complete insertion. November 14, 2002

  24. Complete Update (Example) <Bookview> <Book> <BookId> 1 </BookId> <Title> Data Structure in C++ </Title> <Year>2000</Year> <Author> <first>Michael</first> <last>Savitch</last> </Author> <Publisher> <Name> McHill </Name> <Address>NY,USA</Address> </Publisher> </Book> <Book> …… </Book> </Bookview> Delete / Insert / Replace Note: - Handle XML element as a whole. - Touch all relations under the view definition. November 14, 2002

  25. General Steps for Complete Update Translation • Step1: Local Validation against View Definition • Is a valid update. • Step2: Propagation • Satisfy functional and key dependencies. • Step3: Translation • Transformation of request into database update operation • Step4: Global Validation against the structural Model • Global Integrity Maintenance View Object Decomposition November 14, 2002

  26. General Steps for Complete Update Translation (Example) * Step4 Book Step1-3 Publisher Chapter Author * PhoneBook State Review November 14, 2002

  27. Complete Deletion • Algorithm (Step1-3): • - Isolate the Dependency Island • - Delete Matching tuples from Underlying Relation • - Identify Referencing Peninsulas • - Replacement on foreign key of matching tuple in each Peninsula • Global Integrity Maintenance (Step4): • - Relation in Dependency Island • Its outgoing ownership and subset connection • Delete propagate • Repeatedly, if necessary • - Relation involved in deletions • Referenced • Foreign Key Replacement November 14, 2002

  28. Complete Deletion (Example) User Update XML View: FOR $root IN document(“bookview.xml”) $book IN $root/book [first = “Michael”][last = “Savitch”] UPDATE $root{ DELETE $book } <Bookview> <Book> <BookId>1</BookId> <Title> Data Structure in C++ </Title> <Year>2000</Year> <Author> <first>Michael</first> <last>Savitch</last> </Author> </Book> <Book> <BookId>2</BookId> <Title> JAVA 2 Reference </Title> <Year>1998</Year> <Author> <first> Peter</first> <last> Naughton</last> </Author> </Book> </Bookview> Delete Expected Effect </Bookview> <Book> <BookId>2</BookId> <Title> JAVA 2 Reference </Title> <Year>1998</Year> <Author> <first> Peter</first> <last> Naughton</last> </Author> </Book> </Bookview> November 14, 2002

  29. Complete Deletion (Example) * • Dependency Island • - Referencing peninsula 1. Delete Book 2. Delete 3. Replace Publisher Chapter Author 5. Replace 4. Delete * PhoneBook State Review November 14, 2002

  30. Where we are • Motivation (Why?) • Update Extension for XQuery • Update Mapping • - Correct Translatability • - Complete Update • - Partial Update • Update Extension to Rainbow System • Related Work November 14, 2002

  31. Partial Update • Background Material: • A. M. Keller, View Object for Relational Databases, PhD Thesis, Stanford University • What is Partial Update ? • - Manipulating only a component of the view element. • - The initial request acts on a single base relation • - Work on only the dependency island. • Why? • - Not Reference peninsula --- no Key information • - Not pivot relation ---- translate as complete update November 14, 2002

  32. Partial Update (Example) * Complete Update Update Book Valid Partial Update Update Publisher Chapter Author * PhoneBook State Review November 14, 2002

  33. Partial Deletion • Purpose • Remove a tuple tfrom the dependency island Dw. • Algorithm • - Isolate subtreeDw’ of the dependency island • t Ri • Dw’ rooted at Ri, subtree of Dw • - For Dw’,Delete tuples dependent on t • - For peninsula attached to Dw’ , replacement on the foreign key • Global Integrity Maintenance: • Same as complete deletion November 14, 2002

  34. Partial-deletion (Example) User Update XML View: FOR $root IN document(“BookView.xml”) $author IN $root/book/author[first = “Michael”][last = “Savitch”] UPDATE $root{ DELETE $author } <Bookview> <Book> <BookId>1</BookId> <Title> Data Structure in C++ </Title> <Year>2000</Year> <Author> <first>Michael</first> <last>Savitch</last> </Author> </Book> <Book> <BookId>2</BookId> <Title> JAVA 2 Reference </Title> <Year>1998</Year> <Author> <first> Peter</first> <last> Naughton</last> </Author> </Book> </Bookview> Delete Expected Effect <Bookview> <Book> <BookId> 1 </BookId> <Title> Data Structure in C++ </Title> <Year>2000</Year> </Book> <Book> …… </Book> </Bookview> November 14, 2002

  35. * Partial Deletion (Example) • Dependency Island • - Referencing peninsula Book 1. Delete Publisher Chapter Author 3. Replace 2. Delete * PhoneBook State Review 5. Replace 4. Delete * ReviewWebsite November 14, 2002 Validate Period

  36. Partial Insertion • Purpose • Insert a tuple to the dependency island • Limitation: • Only for ownership connection in dependency island. • Algorithm • - Extend the view tuple with values for the attributes that have been projected out in the view definition • - If new tuple is already present in the instance, reject the update • - Otherwise, perform an insertion in the underlying database relation. • Global Integrity Maintenance: • - Insertion-check for outgoing reference November 14, 2002

  37. Partial-Insertion (Example) User Update Expected Effect FOR $root IN document(“BookView.xml”) $author IN $root/book/author[first = “Michael”][last = “Savitch”] UPDATE $root{ INSERT <first>Joe</first> <last>Smith</last> } <Bookview> <Book> <BookId> 1 </BookId> <Title> Data Structure in C++ </Title> <Year>2000</Year> <Author> <first>Michael</first> <last>Savitch</last> <first>Joe</first> <last> Smith</last> </Author> <Publisher> <Name> McHill </Name> <Address>NY,USA</Address> </Publisher> </Book> <Book> …… </Book> </Bookview> November 14, 2002

  38. * Partial Insertion (Example) • Dependency Island • - Referencing peninsula Book 1. Insert Publisher Chapter Author 2. Insert Check * State University PhoneBook Review * ReviewWebsite November 14, 2002 Validate Period

  39. Where we are • Motivation (Why?) • Update Extension for XQuery • Update Mapping • - Correct Translatability • - Complete Update • - Partial Update • Update Extension to Rainbow System • Related Work November 14, 2002

  40. Mapping Query Default Schema Rainbow Query Engine User Query User Query Results in XML XQuery Parsed Tree Kweelt XQuery Parser XAT Generator Mapping Query XAT View Composition XML View Manager XAT XAT Rewrite XAT XAT Executor SQL Generator XAT SQL Tuples RDBMS November 14, 2002

  41. Mapping Query Default Schema Update Manager within Rainbow User Query User Update User Query Results in XML Update Parser Parsed Tree Kweelt XQuery Parser XAT Generator Mapping Query XAT View Analyzer XAT View Composer XML View Manager Update Decomposer Table Relationships XAT XAT XAT Rewrite Single Table Updates Update Translator SI XAT XAT Executor SQL Node Generation XAT SQL Tuples Multiple SQL updates RDBMS November 14, 2002

  42. Our Approach for Complete Update • Step 1: Analyze mapping query XAT to find • - Find Underlying relations of View • Find Pivot Relation • Analysis Relationship with pivot relation • Dependency Island • Referencing Peninsula • Other Relationship ( used for Global Integrity check) • Step 2: Generate XAT for user update on mapping view • Step 3: Compose two algebra tree • Step 4: Decompose update into updates against individual relations. • Original update should tough only one relation at one time. November 14, 2002

  43. Our Approach for Complete Update Step 6: Use semantic information for correct translation of updates Algorithm for Complete Insert/Delete/Replace Step 7: Generate SQL updates executed in the relational engine. November 14, 2002

  44. Our Approach for Partial Update • Step 1: Generate XAT for mapping query • Step 2: Generate XAT for user update on mapping view • Step 3: Compose two algebra tree • Step 4: Analyze mapping query and user query XAT to find • Find Underlying relations of View • Find Pivot Relation • Analysis Relationship with pivot relation • Dependency Island • Find Original Updating Relation Original-Up • Working on dependency island? YES: continue, NO: complete/reject • Analysis Relationship with Original-Up • sub-dependency island • sub-Referencing Peninsula • Other Relationship ( used for Global Integrity check) November 14, 2002

  45. Our Approach for Partial Update Step 6: Use semantic information for correct translation of updates Algorithm for Complete Insert/Delete/Replace Step 7: Generate SQL updates executed in the relational engine. November 14, 2002

  46. Restrictions on views • View should be in SPJ form • Only select, project and joins are allowed in view definition • View has at least one root relation • Key of table is also key of XML elements in view • No Aggregation in view definition • No aggregate columns such as max( ), count( ) etc • No explicit external dependencies • No element value computed from values of other elements November 14, 2002

  47. Related Work • Umeshwar Dayal, Philip A. Bernstein, On the Updatability of Relational Views, IEEE 1978 • Umeshwar Dayal, Philip A. Bernstein, On the correct Translation of Update Operations on Relationsl Views, ACM Transactions on Database Systems, 1982 • A. M. Keller, Barsalou, Siambela and Wiederhold, Updating Relationsl Databases through Object-Based Views, SIGMOD 1991 • Tatarinov, Ives, Alon Halevy and Daniel Weld, Updating XML, SIGMOD 2001 November 14, 2002

  48. Appendix November 14, 2002

  49. Notation ---- Ownership Connection • R1 is the owner of R2 if: • (a) every tuple in R2 must be connected to an owning tuple in R1 • (b) Deletion of an owning tuple in R1 requires deletion of all tuples connected to that tuple in R2 • (c) Modification of X1 in an owning tuple of R1 requires either propagation of the modification to the matching attributes X2 of all owned tuples in R2 or deletion of those tuples. Book Author X1 = (BookId) X2=(BookNo) R1(Book) is the owner of R2 (Author) R1 * R2 November 14, 2002

  50. Notation ---- Reference Connection • R1 is referencing to R2 if: • (a) Every tuple in R1 must either be connected to a referenced tuple in R2 or have null value for X1 ( the latter is allowed only when X1 NK(R1). • (b) Deletion of a tuple in R2 requires either deletion of its referencing tuples in R1 or assignment of null values to attributes X1 of all the referencing tuples in R1. • (c) Modification of X2 in a referenced tuple of R2 requires any one of the following: propagation of the modification to attributes X1 of all referencing tuples in R1, assignment of null values to attributes X1 of all referencing tuples in R1, or deletion of those tuples. Book Publisher X1 = (Publisher) X2=(PublisherId) R1(Book) is referencing to R2 (Author) R1 R2 November 14, 2002

More Related