


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Various approaches to mapping xml data to relational databases, including text files, object-oriented dbms, and relational dbms. It covers schema-oblivious and schema-aware mapping techniques, node/edge-based and interval-based schema designs, and label-path and dewey-order encoding. The document also explores the advantages and disadvantages of each approach and provides examples of queries using these techniques.
Typology: Slides
1 / 4
This page cannot be seen from the preview
Don't miss anything!



3
4
Simple, compact Full-text indexing can help (often provided by DBMS vendors as object-relational “extensions”) Poor integration with relational query processing Updates are expensive
Schema-oblivious mapping: well-formed XML → generic relational schema
5
Attribute order does not matter
pos specifies the ordering of children child references either Element ( eid ) or Text ( tid )
tid cannot be the same as any eid
6
eid tag e0 bibliography e1 book e2 title e3 author e4 author e5 author e6 publisher e7 year
eid pos child e0 1 e e1 1 e e1 2 e e1 3 e e1 4 e e1 5 e e1 6 e e2 1 t e3 1 t e4 1 t e5 1 t e6 1 t e7 1 t
eid attrName attrValue e1 ISBN ISBN- e1 price 80
tid value t0 Foundations of Databases t1 Abiteboul t2 Hull t3 Vianu t4 Addison Wesley t5 1995
SELECT eid FROM Element WHERE tag = ‘title’;
SELECT e2.eid FROM Element e1, ElementChild c, Element e WHERE e1.tag = ‘section’ AND e2.tag = ‘title’ AND e1.eid = c.eid AND c.child = e2.eid;
//bibliography/book[author=“Abiteboul”]/@price SELECT a.attrValue FROM Element e1, ElementChild c1, Element e2, Attribute a WHERE e1.tag = ‘bibliography’ AND e1.eid = c1.eid AND c1.child = e2.eid AND e2.tag = ‘book’
AND e2.eid = a.eid AND a.attrName = ‘price’;
AND EXISTS (SELECT * FROM ElementChild c2, Element e3, ElementChild c3, Text t WHERE e2.eid = c2.eid AND c2.child = e3.eid AND e3.tag = ‘author’ AND e2.eid = c3.eid AND c3.child = t.tid AND t.value = ‘Abiteboul’)
9
Requires SQL3 recursion WITH ReachableFromBook(id) AS ((SELECT eid FROM Element WHERE tag = ‘book’) UNION ALL (SELECT c.child FROM ReachableFromBook r, ElementChild c WHERE r.eid = c.eid)) SELECT eid FROM Element WHERE eid IN (SELECT * FROM ReachableFromBook) AND tag = ‘title’;
10
left is the start position of the element right is the end position of the element level is the nesting depth of the element (strictly speaking, unnecessary) Key is left
E 1 is the parent of E 2 iff: [ E 1. left , E 1. right ] ⊃ [ E 2. left , E 2. right ], and E 1. level = E 2. level – 1
11
1
book
title author author author publisher year
1,999,
2,21,
3,5,3 6,8,3 9,11,3 12,14,3 15,17,3 18,20,
12
SELECT e2.left FROM Element e1, Element e WHERE e1.tag = ‘section’ AND e2.tag = ‘title’ AND e1.left < e2.left AND e2.right < e1.right AND e1.level = e2.level-1;
SELECT e2.left FROM Element e1, Element e WHERE e1.tag = ‘book’ AND e2.tag = ‘section’ AND e1.left < e2.left AND e2.right < e1.right;
book ( ISBN , publisher_id ) publisher ( id , name_id , address_id ) name ( id , PCDATA_id ) address ( id , PCDATA_id )
book ( ISBN , publisher_name_PCDATA_value , publisher_address_PCDATA_value )
21
//title (SELECT title FROM book) UNION ALL (SELECT title FROM section);
//section/title SELECT title FROM section;
//bibliography/book[author=“Abiteboul”]/@price SELECT price FROM book, book_author WHERE book.ISBN = book_author.ISBN AND author = ‘Abiteboul’; //book//title (SELECT title FROM book) UNION ALL (SELECT title FROM section)
These queries only work for the given DTD
22
23
Each tuple returned by SQL gets converted to an element
Tuples can be returned by SQL in sorted order; adjacent tuples are grouped into an element
One SQL query returns one table whose columns cannot store sets Option 1: return one table with all combinations of authors and references → bad Option 2: return two tables, one with authors and the other with references → join is done as post processing Option 3: return one table with all author and reference columns; pad with NULL’s; order determines grouping → messy
24
Flexible and adaptable; no DTD needed Queries are easy to formulate
Less flexible and adaptable Need to know DTD to design the relational schema Query formulation requires knowing DTD and schema Queries are more efficient XQuery is tougher to formulate because of result restructuring