XML Databases
12. Updates
Silke Eckstein Andreas Kupfer
Institut für Informationssysteme
Technische Universität Braunschweig http://www.ifis.cs.tu-bs.de
1. Finish chapter 11:
– Short recapitulation of XPath Accelerator encoding – 11.6 Staircase join
2. Chapter 12:
Plan for today
2. Chapter 12:
– Updates
3. Tutorial
– Presentation of exercise 8 – Presentation of exercise 9
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 2
11.1 Introduction
11.2 Node-based encoding
11.3 Path-based XPath Accelerator encoding
11. XML storage – details
11.4 Evaluation in SQL
11.5 Skeleton compression 11.6 Staircase join
11.7 Overview and References
• XPath axes in the pre/post plane
– Plane partitions ≡ XPath axes, o is arbitrary!
11.3 XPath Accelerator
– Pre/post plane regions ≡ major XPath axes
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 4 [Gru08]
The major XPath axes descendant, ancestor, following, preceding correspond to rectangular pre/post plane windows.
• XPath Accelerator encoding
– XML fragment f and its skeleton tree
11.3 XPath Accelerator
– Pre/post encoding of f : table accel
• XPath axes and pre/post plane windows
– Window def's for axis α , name test t ( * = don't care)
11.4 Evaluation in SQL
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 6 [Gru08]
• Result of path(·) simplified and unnested
– path(fn:root()/descendant::a/child::text())
11.4 Evaluation in SQL
SELECT DISTINCT v
1.*
FROM accel v3, accel v2,accel v1
WHERE v1 INSIDE window (child::text(), v2) AND v2 INSIDE window (descendant::a, v3)
– An XPath location path of n steps leads to an n-fold self join of encoding table accel.
– The join conditions are
• conjunctions √ of
• range or equality predicates √ .
AND v2 INSIDE window (descendant::a, v3) AND v3 .pre = 0
ORDER BY v1 .pre
}}
multi-dimensional window!11.1 Introduction
11.2 Node-based encoding
11.3 Path-based XPath Accelerator encoding
11. XML storage – details
11.4 Evaluation in SQL
11.5 Skeleton compression 11.6 Staircase join
11.7 Overview and References
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 8
• Enhancing tree awareness
– We now know that the XPath Accelerator is a true
isomorphism with respect to the XML skeleton tree structure.
• Witnessed by our discussion of shredder (ε) and serializer (ε -1) .
– We will now see how the database kernel can benefit
11. 6 Staircase Join
– We will now see how the database kernel can benefit from a more elaborate tree awareness (beyond
document order and semantics of the four major XPath axes).
– This will lead to the design of staircase join ⋈⋈⋈⋈, the core of MonetDB/XQuery's XPath engine.
• Tree awareness?
– Document order and XPath semantics aside, what are further tree properties of value to a relational XML processor?
11. 6 Staircase Join
The size of the subtree rooted in node a is 4
The leaf-to-root paths of nodes b, c meet in node d The subtrees rooted in e and a are necessarily disjoint
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 10 [Gru08]
• Tree awareness : Subtree size
– Tree property subtree size ( on previous slide) is implicitly present in a pre/post-based tree encoding:
– To exploit property subtree size, we were able to find
11. 6 Staircase Join
post(v) - pre(v) = size(v ) - level(v)
– To exploit property subtree size, we were able to find a means on the SQL language level, i.e., outside
the database kernel.
⇒ This led to window shrink-wrapping for the XPath descendant axis.
• Tree awareness on the SQL level
– Shrink-wrapping for the descendant axis
– path(Q)
11. 6 Staircase Join
Q ≡ (c)/following::node()/descendant::node()
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 12 [Gru08, Gru02]
SELECT DISTINCT v2 .pre FROM accel v1, accel v2 WHERE v1.pre > c.pre
AND v1.pre < v2.pre AND v1.post > c.post AND v1.post > v2.post
AND v2.pre <= v1.post + h ANDv2.post >= v1.pre – h ORDER BY v2.pre
• Tree awareness : Meeting ancestor paths
– Evaluation of axis ancestor can clearly benefit from knowledge about the exact element node where several given node-to-root paths meet.
• For example:
For context nodes c1…cn, determine their lowest common ancestor v = lca(c …c ).
11. 6 Staircase Join
1 n
ancestor v = lca(c1…cn).
⇒Above v , produce result nodes once only.
(This still produces duplicate nodes below v.)
– This knowledge is present in the encoding but is not as easily expressed on the level of commonly
available relational query languages (such as SQL or relational algebra).
• Tree awareness : Disjoint subtrees
– An XPath location step cs/α is evaluated for a context node sequence cs.
• This " set-at-a-time" processing mode is key to the efficient
evaluation of queries against bulk data. We want to map this into set-oriented operations on the RDBMS.
11. 6 Staircase Join
set-oriented operations on the RDBMS.
(Remember: location step is translated into join between context node sequence and document encoding table accel.)
– But: If two context nodes ci ,j ∈ cs are in α-relationship, duplicates and out-of-order results may occur.
• Need efficient way to identify the ci ∈∈∈∈ cs which are not in α- relationship with any other cj
(for α = descendant: " ci ,j in disjoint subtrees?").
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 14 [Gru08]
• Staircase Join: An injection of tree awareness
– Since we fail to explain tree properties and at the relational language level interface, we opt to invade the database kernel in a controlled fashion
• Inject a new relational operator, staircase join ⋈⋈⋈⋈s, , , , into the relational query engine.
11. 6 Staircase Join
relational query engine.
• Query translation and optimization in the presence of ⋈⋈⋈⋈s continues to work like before (e.g., selection pushdown).
• The ⋈⋈⋈⋈s algorithm encapsulates the necessary tree knowledge.
⋈
⋈
⋈
⋈s is a local change to the database kernel.
– Remember: All of this is optional. XPath Accelerator is a purely relational XML document encoding, working on top of any RDBMS.
• Tree awareness: Window overlap, coverage
– Location step (c1, c2, c3, c4)/descendant::node().
The pairs (c1, c2) and (c3, c4) are in descendant- relationship:
• Window overlap and coverage (descendant axis)
11. 6 Staircase Join
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 16 [Gru08]
• Tree awareness: Window overlap, coverage
11. 6 Staircase Join
Axis window overlap (descendant axis)
Axis window overlap (ancestor axis)
• Tree awareness: Window overlap, coverage
11. 6 Staircase Join
Axis window overlap (following axis)
Axis window overlap (preceding axis)
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 18 [Gru08]
• Context node sequence pruning
– We can turn these observations about axis window overlap and coverage into a simple strategy to prune the initial context node sequence for an XPath location step.
11. 6 Staircase Join
location step.
• Context node sequence pruning
Given cs/α determine minimal cs− ⊆ cs, such that
cs/α = cs − /α .
We will see that this minimization leads to axis step evaluation on the pre/post plane, which never emits duplicate nodes or out-of-order results.
• Context node pruning: following axis
– Once context pruning for the following axis is complete, all remaining context nodes relate to each other on the ancestor/descendant axes:
• Covering nodes c , c in descendant relationship
11. 6 Staircase Join
• Covering nodes c1, c2 in descendant relationship
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 20 [Gru08]
• Empty regions in the pre/post plane
11. 6 Staircase Join
Relating two context
nodes (c1, c2) on the plane
Empty regions?
Given c1,2 on the left, why are the regions U,S marked Ø guaranteed to not hold any nodes?
to not hold any nodes?
• Context pruning (following axis)
– (c1, c2)/following::node()
11. 6 Staircase Join
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 22 [Gru08]
(c1, c2)/following::node() ≡ S ∪ T ∪ W
≡ T ∪ W
≡ (c2)/following::node()
• Context pruning (following axis)
11. 6 Staircase Join
Context pruning (following axis)
Replace context node sequence cs by singleton sequence (c), c ∈ cs, with post(c) minimal.
• Context pruning (preceding axis)
11. 6 Staircase Join
Context pruning (preceding axis)
Replace context node sequence cs by singleton sequence (c), c ∈ cs, with pre(c) maximal.
– Regardless of initial context size, axes following and preceding yield simple single region queries.
– We focus on descendant and ancestor now.
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 24 [Gru08]
• More empty regions
11. 6 Staircase Join
Remaining context nodes c1, c2 after pruning for descendant axis
Empty region?
Why is region Z marked Ø guaranteed to be empty?
• Context pruning (descendant axis)
11. 6 Staircase Join
• The region marked Ø above is a region of type Z (previous slide). In general, a non-singleton sequence remains.
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 26 [Gru08]
• Context pre-processing: Pruning
– prune_contextdesc(context : TABLE(pre,post))
11. 6 Staircase Join
• " Staircases" in the pre/post plane
– Note that after context pruning, the remaining context nodes form a proper "staircase" in the plane. (This is an important assumption in the following.)
• Context pruning & "staircase"
11. 6 Staircase Join
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 28 [Gru08]
• Flashback: Intersecting ancestor paths
– Even with pruning applied, duplicates and out-of-order results may still be generated due to intersecting ancestor paths.
• We have observed this before: apply function ancestors(c1, c2) where c1 (c2) denotes the element node with tag d (e) in the sample tree below.
(Nodes c1,2, would not have been removed during pruning.)
11. 6 Staircase Join
(Nodes c1,2, would not have been removed during pruning.)
Remember: ancestors((d,e)) yielded (a,b,a,c).
Sample tree Simulate XPath ancestor via parent axis
declare function
ancestors($n as node()*) as node()*
{ if (fn:empty($n)) then ()
else (ancestors($n/..), $n/..) }
11. 6 Staircase Join
• Separation of ancestor paths
– Idea: try to separate the ancestor paths by defining suitable cuts in the XML fragment tree.
• Stop node-to-root traversal if a cut is encountered.
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 30 [Gru08]
Path separation (ancestor axis)
• Parallel scan along the pre dimension
– Separating ancestor paths
11. 6 Staircase Join
Scan partitions (intervals): [p0, p1), [p1, p2), [p2, p3).
• Can scan in parallel. Partition results may be concatenated.
• Context pruning reduces numbers of partitions to scan.
• Basic Staircase Join (descendant)
– ⋈⋈⋈⋈s desc(accel: TABLE(pre,post), context : TABLE(pre,post))
11. 6 Staircase Join
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 32 [Gru08]
• Partition scan (sub-routine)
– scanpartition(pre1 ,pre2 , post; Ɵ)
11. 6 Staircase Join
Notation accel[i] does not imply random access to document encoding:
• Access is strictly forward sequential (also between invocations of scanpartition(·)).
• Basic Staircase Join (ancestor)
– ⋈
anc(accel : TABLE(pre,post), context : TABLE(pre,post))
11. 6 Staircase Join
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 34 [Gru08]
• Basic Staircase Join: Summary
– The operation of staircase join is perhaps most closely described as merge join with a dynamic range
predicate: the join predicate traces the staircase boundary:
• ⋈⋈⋈⋈ scans the accel and context tables and populates the result
11. 6 Staircase Join
• ⋈⋈⋈⋈s scans the accel and context tables and populates the result table sequentially in document order,
• ⋈⋈⋈⋈s scans both tables once for an entire context sequence,
• ⋈⋈⋈⋈s never delivers duplicate nodes.
– ⋈⋈⋈⋈s works correctly only if prune_context(·) has previously been applied.
• prune_context(·) may be inlined into ⋈⋈⋈⋈s , thus performing context pruning on-the-fly.
• Skip ahead, if possible
– While scanning the partition associated with c1,2 :
– v is outside staircase boundary, thus not part of the result.
– No node beyond v in result (Ø-region of type Z).
⇒ Can terminate scan early and skip ahead to pre(c2).
11. 6 Staircase Join
(c ;c )/descendant::node()
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 36 [Gru08]
(c
1;c
2)/descendant::node()
• Skipping for the descendant axis
– scanpartitiondesc(pre1 ,pre2 , post)
11. 6 Staircase Join
– Note: keyword break transfers control out of innermost enclosing loop (cf. C, Java).
• Effectiveness of skipping
– Enable skipping in scanpartition(·). Then, for each node in context, we either
1. hit a node to be copied into table result, or
2. encounter an offside node (node v on previous slide) which
11. 6 Staircase Join
2. encounter an offside node (node v on previous slide) which leads to a skip to a known pre value (→ positional access).
– To produce the final result, ⋈⋈⋈⋈s thus never touches more than
context + result nodes in the plane (without skipping: context + accel).
• In practice: > 90% of nodes in table accel are skipped.
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 38 [Gru08]
• "Database-Supported XML Processors", [Gru08]
– T. Grust
– Lecture, Uni Tübingen, WS 08/09
• "XML and Databases", [Scholl07]
– M. Scholl
– Lecture, Uni Konstanz, WS07/08
• "Staircase Join: Teach a Relational DBMS to Watch its (Axis) Steps"
11.7 References
• "Staircase Join: Teach a Relational DBMS to Watch its (Axis) Steps"
[GKT03]
– Torsten Grust, Maurice van Keulen, Jens Teubner.
– In Proc. 29th Int'l Conference on Very Large Databases (VLDB), pages 524- 535, 2003.
– http://www.informatik.uni-konstanz.de/~grust/files/staircase-join.pdf
• " Accelerating XPath Location Steps" [Gru02]
– T. Grust
– ACM SIGMOD 2002, June 4–6, Madison, Wisconsin, USA
– http://www-db.informatik.uni-tuebingen.de/files/publications/xpath-accel.pdf
1. Finish chapter 11:
– Short recapitulation of XPath Accelerator encoding
– 11.6 Staircase join
2. Chapter 12:
Plan for today
2. Chapter 12:
– Updates
3. Tutorial
– Presentation of exercise 8 – Presentation of exercise 9
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 40
12.1 Introduction
12.2 XQuery Update Facility
12.3 Impact on XPath Accelerator Encoding
12. Updates
12.4 Overview and References
• Throughout the course, up to now, we have not been looking into updates to XML documents at all.
– If we want to discuss efficiency/performance issues w.r.t.
mappings of XML documents to databases, though, we need to take modifications into account as well as pure retrieval operations.
12.1 Introduction
retrieval operations.
– As always during physical database design, there is a trade- off between accelerated retrieval and update performance.
– The following examples are formulated in XQuery
Update, an extension to XQuery that currently has W3C Candidate Recommendation status
(http://www.w3.org/TR/xquery-update-10/).
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 42 [Gru08]
• Updates and tree structures
– During our discussion of XQuery, we have seen that tree construction has been a major concern. Updates, however, cannot be expressed with XQuery.
• Yet, we need to be able to specify modifications of existing XML documents/fragments as well.
12.1 Introduction
documents/fragments as well.
• We certainly need to be able to express:
– modification of all aspects (name, attributes, attribute values, text contents) of XML nodes, and
– modifications of the tree structure (insert/delete/replace nodes or subtrees) and to rename and transform them.
• Like in the SQL case, target node(s) of such modifications should be identifiable by means of queries.
12.1 Introduction
12.2 XQuery Update Facility
12.3 Impact on XPath Accelerator Encoding
12. Updates
12.4 Overview and References
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 44
• XQuery Update Facility: New XQuery expressions
12.2 XQuery Update Facility
XQuery expressions
ExprSingle ::= FLWORExpr
| QuantifiedExpr
| TypeswitchExpr
| IfExpr
| InsertExpr
Syntax and examples taken from the W3C
– N.B. Updating expressions (insert, delete, rename, replace) lead to a loss of type/validation information at the affected nodes.
Such information may be recovered by revalidation.
| InsertExpr
| DeleteExpr
| RenameExpr
| ReplaceExpr
| TransformExpr
| OrExpr
taken from the W3C web site.
• Node insertion
– An insert expression is an updating expression that inserts copies of zero or more nodes into a designated position with respect to a target node.
12.2 XQuery Update Facility
Syntax
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 46 [Scholl07]
Syntax
InsertExpr ::= "insert" ("node" | "nodes")
SourceExpr InsertExprTargetChoice TargetExpr InsertExprTargetChoice ::= (("as" ("first" | "last"))? "into")
| "after" | "before"
SourceExpr ::= ExprSingle TargetExpr ::= ExprSingle
• Node insertion: Examples
12.2 XQuery Update Facility
Insert a year element after the publisher of the first book.
insert node <year>2005</year>
after fn:doc("bib.xml")/books/book[1]/publisher
Navigating by means of several bound variables, insert a new police report into the list of police reports for a particular accident.
insert node $new-police-report
as last into fn:doc("insurance.xml")/policies /policy[id = $pid]
/driver[license = $license]
/accident[date = $accdate]
/police-reports
• Node deletion
– A delete expression deletes zero or more nodes from an XDM instance.
– The keywords node and nodes may be used interchangeably, regardless of how many nodes are actually deleted.
12.2 XQuery Update Facility
Syntax
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 48 [Scholl07]
Syntax
DeleteExpr ::= "delete" ("node" | "nodes") TargetExpr TargetExpr ::= ExprSingle
Delete the last author of the first book in a given bibliography.
delete node
fn:doc("bib.xml")/books/book[1]/author[last()]
Delete all email messages that are more than 365 days old.
delete nodes /email/message
[fn:currentDate() - date > xs:dayTimeDuration("P365D")]
• Node replacement
– Replace takes two forms, depending on whether value of is specified:
12.2 XQuery Update Facility
Syntax
ReplaceExpr ::= "replace" ("value" "of")? "node"
TargetExpr "with" ExprSingle TargetExpr ::= ExprSingle
– Replace takes two forms, depending on whether value of is specified:
• If value of is not specified, a replace expression replaces one node with a new sequence of zero or more nodes. The replacement nodes occupy the position in the node hierarchy that was formerly occupied by the node that was replaced.
– Hence, an attribute node can be replaced only by zero or more attribute nodes, and an element, text, comment, or processing instruction node can be replaced only by zero or more element, text, comment, or processing
instruction nodes.
• If value of is specified, a replace expression is used to modify the value of a node while preserving its node identity.
• Node replacement: Examples
12.2 XQuery Update Facility
Replace the publisher of the first book with the publisher of the second book.
replace node fn:doc("bib.xml")/books/book[1]/publisher with fn:doc("bib.xml")/books/book[2]/publisher
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 50 [Scholl07]
Increase the price of the first book by ten percent.
replace value of node fn:doc("bib.xml")/books/book[1]/price with fn:doc("bib.xml")/books/book[1]/price * 1.1
• Renaming nodes
– A rename expression replaces the name property of a data model node with a new QName.
12.2 XQuery Update Facility
Syntax
RenameExpr ::= "rename" "node" TargetExpr "as"
NewNameExpr NewNameExpr
Rename the first author element of the first book to principal-author.
rename node fn:doc("bib.xml")/books/book[1]/author[1]
as "principal-author"
Rename the first author element of the first book to the QName that is the value of the variable $newname.
rename node fn:doc("bib.xml")/books/book[1]/author[1]
as $newname
• Renaming is local!
– The effects of a rename expression are limited to its target node, descendants are not affected.
Global change of names or namespaces needs explicit iteration.
12.2 XQuery Update Facility
Example (Change all QNames from prefix abc to xyz and new namespace URI http://xyz/ns for node $root and its decendents.)
for $node in $root//abc:*
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 52 [Scholl07]
for $node in $root//abc:*
let $localName := fn:local-name($node),
$newQName := fn:concat("xyz:", $localName) return
rename node $node as fn:QName("http://xyz/ns", $newQName), for $attr in $node/@abc:*
let $attrLocalName := fn:local-name($attr),
$attrNewQName := fn:concat("xyz:", $attrLocalName) return
rename node $attr as fn:QName("http://xyz/ns",
$attrNewQName)
• Node transformation
– . . . creates modified copies of existing nodes. Each copied node obtains a new node identity. The resulting XDM instance can contain both, newly created and previously existing nodes.
Node transformation is a non-updating expression, since it does not modify existing nodes!
12.2 XQuery Update Facility
Syntax
– Idea:
1. Bind variables of copy clause (non-updating expressions), 2. update copies (only!) as per modify clause,
3. construct result by return (copied/modified and/or other nodes).
Syntax
TransformExpr ::= "copy" "$"VarName ":=" ExprSingle ("," "$"VarName ":=" ExprSingle)*
"modify" ExprSingle
"return" ExprSingle
• Node transformation: Examples
12.2 XQuery Update Facility
Return a sequence consisting of all employee elements that have Java as a skill, excluding their salary child-elements.
for $e in //employee[skill = "Java"]
return
copy $je := $e
modify delete node $je/salary
– N.B. Underlying persistent data not changed by these examples!
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 54 [Scholl07]
modify delete node $je/salary return $je
Copy a node, modify copy, then return original and modified copy.
let $oldx := /a/b/x return
copy $newx := $oldx
modify (rename node $newx as "newx",
replace value of node $newx by $newx * 2) return ($oldx, $newx)
• On the semantics of the XQuery Update Facility
– Formally specifying the exact semantics of the XQuery UF is non-trivial for several reasons:
• Formal update semantics are always a lot more involved
12.2 XQuery Update Facility
• Formal update semantics are always a lot more involved than retrieval semantics.
• Updates and bulk operations do not go together well (cf.
SQL set-oriented updates).
• XUF uses a notion of "snapshots" and "pending update lists"
to work around some of the subtleties.
• The details are beyond the scope of this lecture.
12.1 Introduction
12.2 XQuery Update Facility
12.3 Impact on XPath Accelerator Encoding
12. Updates
12.4 Overview and References
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 56
• Text node updates
– Obviously, replacing the value of a text (or attribute,
comment, processing instruction) node has little impact on the XML representation.
12.3 Impact on XPath Acc. Enc.
Replacing text by text
<a>
<b id="0">foo</b>
<b id="1">bar</b>
</a>
⇓
⇓⇓
⇓ replace text "bar" by "foo"
<a>
<b id="0">foo</b>
<b id="1">foo</b>
</a>
• Text node updates
– Translated into, e.g., the XPath Accelerator representation, we see that
• Replacing text nodes by text nodes has local impact only on the pre/post encoding of the updated tree.
12.3 Impact on XPath Acc. Enc.
The update leads to a local relational update
• Similar observations can be made for updates on comment and processing instruction nodes.
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 58 [Scholl07]
The update leads to a local relational update
⇒⇒
⇒⇒
⇒⇒
⇒⇒
• Structural updates
12.3 Impact on XPath Acc. Enc.
Inserting a new subtree
<a>
<b><c><d/><e/></c></b>
<f><g/>
<h><i/><j/></h>
</f>
⇓⇓
⇓⇓
– Question: What are the effects w.r.t. our structure encoding. . . ?
</f>
</a>
⇓⇓
⇓⇓ insert node <k><l/><m/></k> into /a/f/g
<a>
<b><c><d/><e/></c></b>
<f><g><k><l/><m/></k></g>
<h><i/><j/></h>
</f>
</a>
• Insertion: Global impact on encoding
– Global shifts in the pre/post plane
12.3 Impact on XPath Acc. Enc.
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 60 [Scholl07]
• Insertion: Global impact on pre/post plane
12.3 Impact on XPath Acc. Enc.
Insert a subtree of n nodes below parent element v
1. post(v) ← post(v) + n
2. ∀ v' ∈ v/following::node():
pre(v') ← pre(v') + n; post(v') ← post(v') + n 3. ∀ v' ∈ v/ancestor::node():
←
∀ ∈
← ←
3. ∀ v' ∈ v/ancestor::node():
post(v') ← post(v') + n
Update cost
3. is not so much a problem of cost but of locking. Why?
Cost (tree of N nodes) O(N) + O(log N)
2.
2. 3.3.
1. Introduction 2. XML Basics
3. Schema definition
4. XML query languages I 5. Mapping relational data
8. XML query languages II – XQuery Data Model
9. XML query languages III – XQuery
10. XML storage I –
12.4 Overview
5. Mapping relational data to XML
6. SQL/XML
7. XML processing
10. XML storage I – Overview
11. XML storage II 12. Updates
13.Systems
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 62
• "Database-Supported XML Processors", [Gru08]
– T. Grust
– Lecture, Uni Tübingen, WS 08/09
• "XML and Databases", [Scholl07]
12.4 References
• "XML and Databases", [Scholl07]
– M. Scholl
– Lecture, Uni Konstanz, WS07/08
• Now, or ...
• Room: IZ 232
• Office our: Tuesday, 12:30 – 13:30 Uhr
Questions, Ideas, Comments
• Office our: Tuesday, 12:30 – 13:30 Uhr or on appointment
• Email: eckstein@ifis.cs.tu-bs.de
XML Databases – Silke Eckstein – Institut für Informationssysteme – TU Braunschweig 64