View
219
Download
0
Category
Preview:
Citation preview
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 1/34
© 2010 IBM Corporation
Information Management
Information Management Ecosystem PartnershipsIBM Canada Lab
Summer/Fall 2010
DB2®
pureXML
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 2/34
2 © 2010 IBM Corporation
Information Management
Agenda
■ Overview of XML
■ pureXML in DB2
■ XML Data Movement in DB2
■ XQuery and SQL/XML
■ XML Indexes in DB2
■ Appi!ation Deveopment
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 3/34
© 2010 IBM Corporation
Information Management
!"at i# XML$
■ eXtensi"e Mar#up Language %XML i# a language de#igned
to de#&ri'e data
■ A $ierar!$i!a data mode
%"oo#&
%aut$ors&
%aut$or id'()*(&+o$n Doe%/aut$or&%aut$or id'(,-(&.eter .an%/aut$or&
%/aut$ors&
%tite&Data"ase systems%/tite&
%/"oo#&
Fle(i'leDe#&ri'e#
it#elf )a#* to
#"are
)a#* toe(tend
+lataformIndependent
,endor Independent
C"ara&teri#ti&# of XML
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 4/34
- © 2010 IBM Corporation
Information Management
!"o .#e# XML$
Banking IFX, OFX, SWIFT, SPARCS,
MISMO +++
Financial Markets
FIX Protocol, FIXML, MDDL,
RIXML, FpML +++
Insurance
ACORD
XML for P&C, Life +++
Chemical & Petroleum
Chemical eStanar!
C"#erSec$rit"
PDX Stanar+++
Healthcare
%L, DICOM, S'OM(D,
LOI'C, SCRIPT +++
Life Sciences MIAM(, MA)(,
LSID, %L, DICOM,
CDIS, LA*, ADaM +++
Retail IXRetail, CC'(T, (A'CC
ePC 'et-or. +++
Electronics
PIP!, R'IF, *$!ine!! Director",
Open Acce!! Stanar! +++
Automotive
e#XML,
other */* St!0
elecommunications
eTOM, ')OSS, etc0
Parla" Specification +++
Energ! & "tilities
I(C Wor.in1 )ro$p 23M$ltiple Stanar!
CIM, M$lti!pea.Cross In#ustr!
PD(S4ST(Pml
SMPI Stanar!
RFID, DOD XML+++
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 5/34
© 2010 IBM Corporation
Information Management
XML Do&ument Component#
'oo
aut"or#
aut"or id34-56+o$n Doe/aut"or
aut"or id3476.eter .an/aut"or
/aut"or#titleData"ase systems/title
pri&e2/pri&e
e*8ord#
e*8ordSQL/e*8ord
e*8ordreationa/e*8ord/e*8ord#
/'oo
)lement
Attri'ute
9e(t node :Data;
<oot element
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 6/34
= © 2010 IBM Corporation
Information Management
9"e XML Data Model> ?ode 9*pe#
'oo
aut"or#
aut"or id34-56+o$n Doe/aut"or
aut"or id3476.eter .an/aut"or
/aut"or#
titleData"ase systems/title
pri&e2/pri&e
e*8ord#e*8ordSQL/e*8ord
e*8ordreationa/e*8ord
/e*8ord#
/'oo
'oo
aut"or# e*8ord#
id3-5 id37
aut"or
S@L relational+eter +ano"n Doe
2Data'a#e#*#tem#
title pri&e
aut"or e*8ord e*8ord
?ode 9*pe#Do&ument node
)lement node#
Attri'ute node#
9e(t node#
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 7/345 © 2010 IBM Corporation
Information Management
!ellFormed ,er#u# ,alid XML Do&ument#
■ A we0formed XML do!ument is a do!ument t$at foows
"asi! rues11; It mu#t "ae one and onl* one root element2; )a&" element 'egin# 8it" a #tart tag and end# 8it" an end tag; An element &an &ontain ot"er element#E attri'ute#E or te(t node#-; Attri'ute alue# mu#t 'e en&lo#ed in dou'le uote#G 9e(t node#E
on t"e ot"er "andE #"ould notG:iGeG it &an 'e par#ed '* an XML par#er 8it"out error;
■ A vaid XML do!ument is BO311; A 8ellformed XML do&ument2; A do&ument &ompliant 8it" t"e rule# defined in an XML #&"ema
do&ument or a Do&ument 9*pe Definition :D9D; do&umentG
XML +ar#er# &an optionall* perform 4alidation6
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 8/34 © 2010 IBM Corporation
Information Management
?atie XML Storage
■ Do!uments are stored in parsed representation
&u#tomerInfo&u#otmer id 3H1H
name4i!tor /name#e(M/#e(p"one t*pe3H8orH*5062*)/p"one
/&u#tomer&u#tomer id 3H2H
nameApri/name#e(7/#e(p"one t*pe3H"omeH-5026*/p"one
/&u#tomer
/&u#tomerInfo
&u#tomerInfo
&u#tomer &u#tomer
Id3666 Id3626name #e( p"one name #e( p"one
t*pe 34wor#6
5125- t*pe 34$ome6
7215M,i&tor F April
Serialiation
XML +ar#ingDo!ument
O"8e!tMode
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 9/3410 © 2010 IBM Corporation
Information Management
<elational ,er#u# Jierar&"i&al :XML; Model
9eationa 3ierar!$i!a :XML;
<elational data i# flat XML data i# ne#tedG
<elational model i# #et orientedGSet# are unorderedG
XML retriee# #euen&e# :t"e ordermatter#;
<elational data i# #tru&turedG XML data i# #emi#tru&turedG
<elational data "a# a #trong #&"emaEunliel* to &"ange oftenG
XML data "a# a fle(i'le #&"emaEappropriate for &on#tant &"ange#G
.#e ?.LL for an unno8n #tateG ?.LLS donKt e(i#tG DonKt add an*XML elementG
Ba#ed on t"e A?SI/IS indu#tr*#tandard#G
Ba#ed on t"e !C indu#tr*#tandard#G
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 10/3411 © 2010 IBM Corporation
Information Management
+ureXML Storage in DB2> XML Data 9*pe
&u#tomerInfo
&u#tomer &u#tomer
Id3666 Id3626name #e( p"one name #e( p"one
t*pe 34wor#6
5125- t*pe 34$ome6
7215M,i&tor F April
DB2 #torage
deptID <<< !ustDo!
A001 GGG
GGG GGG GGG
CREATE TABLE dept (deptID VARCHAR(30), ..., custDoc XML)
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 11/34
12 © 2010 IBM Corporation
Information Management
XML ?ode Storage La*out
■ =ode $ierar!$y of an XML do!ument is stored on DB2 pages
■ Do!uments t$at don>t fit on 6 page are spit into pages /regions
■ =o ar!$ite!tura imit for si?e of XML do!uments
■ =odeIDs are used to identify individua nodes
6
6<66<2 6<5
6<2<6<6<,<5
6<5<2
6<5<6<5
Do&ument #plit into region#E #tored on page#GG
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 12/34
1 © 2010 IBM Corporation
Information Management
XML Data> A# 9ree# on DB2 +age#
<<<
pagepage pageta"e spa!e
A "enefits of DB2 ta"espa!es
%Buffered in Buffer +ool# %+refet&"ing %Logging <e&oer*
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 13/34
1- © 2010 IBM Corporation
Information Management
XML Storage> Internal 'Ne&t# and 9"eir <elation#"ip
deptID <<< !ustDo!
A001 GGG
A002 GGG
GGG GGG
<egion
Inde(
I?X 'Ne&t
XDA 'Ne&t
DA9 'Ne&t
Lie LB#E XMLdata i# #tored#eparatel* fromt"e 'a#e ta'le:unle## inlined;
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 14/34
1 © 2010 IBM Corporation
Information Management
Jo8 to Oet Data In$
■ Impi!it XML parsing1
%In#erting data of XML data t*pe into a &olumn
■ @xpi!it XML.A9S@ %9ran#form XML alue from #erialied :te(t; form into internal
repre#entationG %9ell #*#tem "o8 to treat 8"ite#pa&e# :#trip/pre#ere;
P Default i# KStrip !JI9)S+AC)K
INSERT INTO dept VALUES
(‘PR27’, …, !dept"#!e$p"#!%e$p"#!%dept"&)
INSERT INTO dept VALUES (‘PR27’, '$p*se(docu$e+t !"...!%"));INSERT INTO dept VALUES (‘PR27’,
'$p*se(docu$e+t !"...!%" p*ese*-e /tespce));
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 15/34
1= © 2010 IBM Corporation
Information Management
Deleting XML Data
■ D@L@@
%!ill delete eer* XML do&ument for a ro8
%Qou &an al#o delete 'a#ed on t"e XML &ontent
■ =ote1 Setting an XML !oumn to =LL deetes t$e XMLdo!ument
DELETE FROM dept 1HERE deptID2A00&
DELETE FROM dept 1HEREXMLEXISTS (4d%%p/o+e5t6pe27Ho$e78
pss+9 IN:O s 7d7)
UPDATE dept SET custDoc 2 N;LL WHERE deptID!A""#’
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 16/34
15 © 2010 IBM Corporation
Information Management
Import
$%p&'t '&% %dt%dept.de & de*ML '&% %dt%'$<es
$+e't $+t& dept
000,7!XDS :IL2C.'$ %"7
00,7!XDS :IL2C=.'$ %"7
00=,7!XDS :IL2C3.'$ %"7
003,7!XDS :IL2C>.'$ %"7
00>,7!XDS :IL2C?.'$ %"7
-d.t.-/%$e-C.'$
-d.t.-/%$e-C=.'$
-d.t.-/%$e-C3.'$
-d.t.-/%$e-C>.'$
-d.t.-/%$e-C?.'$
1000 deptemplo*eenameo"n Doe/nameaddre###treet Baile* Ae/#treet&it*R/&it*ip1-1/ip/addre##R/emplo*ee/dept
1001 deptemplo*eenameat"* Smit"/name R
1002 deptemplo*eenameim ?oodle RG
/data/dept<de
/data/xmfies
dept
D)L file to import
Dire&tor* t"at in&lude#t"e XML file# t"at arereferen&ed in t"e D)L file
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 17/34
17 © 2010 IBM Corporation
Information Management
)(portE*PORT TO %dt%dept.de & DEL*ML TO %dt%'$<es
*MLFILE deptd&0MODIFIED 1 *MLINSEPFILES
SELE3T 4 FROM dept
1000 deptemplo*eenameo"n Doe/name
addre###treet Baile* Ae/#treet&it*R/&it*ip1-1/ip/addre##R/emplo*ee/dept
1001 deptemplo*eenameat"* Smit"/name R
1002 deptemplo*eenameim ?oodle RG
dept
000,7!XDS :IL2C.'$ %"7
00,7!XDS :IL2C=.'$ %"7
00=,7!XDS :IL2C3.'$ %"7
003,7!XDS :IL2C>.'$ %"7
00>,7!XDS :IL2C?.'$ %"7
-d.t.-/%$e-C.'$
-d.t.-/%$e-C=.'$
-d.t.-/%$e-C3.'$
-d.t.-/%$e-C>.'$
-d.t.-/%$e-C?.'$
/data/dept<de /data/xmfies
D)L file to output
Dire&tor* to pla&e XML file#
Ba#e name for e(ported XML file#
Store ea&" XML do&ument in #eparate file:ptionall*> Con&atenate all XMLdo&ument# in one large fileG;
!"at to e(port
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 18/34
1 © 2010 IBM Corporation
Information Management
S@L/XML and X@uer*
■ DB2 Supports two uery anguages1
%XQuery %SQL/XML
■ X.at$ %Corner#tone for 'ot" X@uer* and S@L/XML #tandard %+roide# a'ilit* to naigate 8it"in XML do&ument#
■ XQuery %98o important fun&tion# to a&&e## t"e data'a#e>
P d'2fn>#luer*P d'2fn>(ml&olumn
%<e#ult# returned a# a #euen&e of item#
■ SQL/XML %+roide# fun&tion# to 8or 8it" 'ot" XML and relation data at t"e
#ame timeG
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 19/34
20 © 2010 IBM Corporation
Information Management
X+at"
&u#tomerInfo
&u#tomerInfo
&u#otmer id 3H1Hname4i!tor /name#e(M/#e(p"one t*pe3H8orH*5062*)/p"one
/&u#tomer&u#tomer id 3H2H
nameApri/name#e(7/#e(p"one t*pe3H"omeH-5026*/p"one
/&u#tomer/&u#tomerInfo
&u#tomer &u#tomer
Id3666 Id3626name #e( p"one name #e( p"one
t*pe 34wor#6
5125- t*pe 34$ome6
7215M,i&tor F April
+at" 9a'le
/
/&u#tomerInfo
/&u#tomerInfo/&u#tomer/Tid
/&u#tomerInfo/&u#tomer/name
/&u#tomerInfo/&u#tomer/#e(
/&u#tomerInfo/&u#tomer/p"one
/&u#tomerInfo/&u#tomer/p"one/Tt*pe
+ar#e
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 20/34
21 © 2010 IBM Corporation
Information Management
Some Common X+at" )(pre##ion#
/ Sele&t# from t"e root nodeG
// Sele&t# node# in t"e do&ument from t"e&urrent node t"at mat&" t"e #ele&tG
te(t:; Spe&ifie# t"e te(t node under an elementG
T Spe&ifie# an attri'uteG
U Mat&"e# an* element nodeG
TU Mat&"e# an* attri'ute nodeG
V R W +redi&ate#
&u#tomerInfo
&u#otmer id 3H1Hname4i!tor /name#e(M/#e(p"one t*pe3H8orH*5062*)/p"one
/&u#tomer&u#tomer id 3H2H
nameApri/name#e(7/#e(p"one t*pe3H"omeH-5026*/p"one
/&u#tomer/&u#tomerInfo
X.at$ @xpression 9esut Des!ription 9esut
-05t&%e'I+&-4-p6&+e-te/t() Sele&t# t"e te(t node under t"e p/o+e element of custo$e*I+<o
@3=@>3=@
-05t&%e'I+&--p6&+e-t8pe Sele&t# t"e t*pe attri'ute under t"e p/o+e element of custo$e*I+<o
o*/o$e
-05t&%e'I+&-05t&%e'9#:-p6&+e-te/t() Sele&t# t"e p/o+e element te(tnode under t"e fir#t custo$e* ofcusto$e*I+<o
@3=@>
-05t&%e'I+&--p6&+e9t8pe!6&%e!: Sele&t# all p/o+e element# undercuso$te*I+<o 8"i&" "a# anattri'ute named t*pe 8it" a alueof K"omeK
!p/o+et6pe2/o$e"3=@ !%p/o+e"
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 21/34
22 © 2010 IBM Corporation
Information Management
Introdu&tion to X@uer*
■ ni#e reationa data :w$i!$ is predi!ta"e and $as a reguar
stru!ture;C XML data is1 %ften unpredi!ta"e
%Jig"l* aria'le
%Spar#e
%Selfde#&ri'ing
■ ou may need XML ueries to perform t$e foowing operations1
%Sear&" XML data for o'Ne&t# t"at are at unno8n leel# of t"e
"ierar&"* %+erform #tru&tural tran#formation# on t"e data
%<eturn re#ult# t"at "ae mi(ed t*pe#
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 22/34
2 © 2010 IBM Corporation
Information Management
DB2 X@uer* Fun&tion#
■ o o"tain XML data from a DB2 data"ase wit$ XQuery
%dF=<+G'$cou$+ ( '$cou$++$e )
P Input argument i# a #tring literal t"at identifie# an XML &olumn in ata'leE &a#e #en#itie
'ue*6 dF=<+G'$cou$+(C;STOMER.IN:O)%custo$e*+<o
P <etriee# an entire XML &olumn a# a #euen&e of XML alue#
%dF=<+Gsue*6 ( <useectsstte$e+t )
P Input argument i# interpreted a# an S@L #tatement and par#ed '*t"e S@L par#er
P S@L #tatement need# to return a #ingle XML &olumn
'ue*6dF=<+Gsue*6(SELECT IN:O :ROM C;STOMER 1HERE CID2J&)%custo$e*+<o
P <eturn# an XML #euen&e t"at re#ult# from t"e full #ele&t
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 23/34
2- © 2010 IBM Corporation
Information Management
X@uer*> <etrieing XML Data From a Column
■ d"20fn1xm!oumn
%<etriee all XML do&ument# from an XML &olumnE t"en pro&e##t"em 8it" an X@uer* e(pre##ionG
XMLCUSTOMER
EID I=7O
6FF6
6FF2
6FF5
xquery db2-fn:xmlcolumn("XMLCUSTOMER.!O "#$
xquery db2-fn:xmlcolumn("XMLCUSTOMER.!O"#%cu&'omernfo%n)me$
name
… …
name
… …
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 24/34
2 © 2010 IBM Corporation
Information Management
X@uer*> <etrieing XML Ba#ed on a S@L @uer*
■ d"20fn1suery
%<etriee and XML do&ument u#ing S@LE t"en pro&e## it 8it" anX@uer* e(pre##ion
%Allo8# filtering 'a#ed on relational data
XMLCUSTOMER
EID I=7O
6FF6
6FF2
6FF5
xquery db2-fn:&qlquery( "SELECT !O
ROM XMLCUSTOMER *+ERE C,//"#$
xquery db2-fn:&qlquery("SELECT !O ROM
XMLCUSTOMER *+ERE C,//"#%cu&'omernfo%n)me$
name
… …
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 25/34
2= © 2010 IBM Corporation
Information Management
S@L/XML Fun&tion#
■ XQuery !an "e invo#ed from SQL
%XMLK;ER()
%XMLTABLE()
%XMLEXISTS()
■ By exe!uting XQuery expressions from wit$in t$e SQL!ontextC you !an1
%perate on part# of #tored XML do&ument# in#tead of entire XMLdo&ument#
%)na'le XML data to parti&ipate in S@L uerie# %perate on 'ot" relational and XML data
%Appl* furt"er S@L pro&e##ing to t"e returned XML alue#
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 26/34
25 © 2010 IBM Corporation
Information Management
S@L/X@uer*> XML Data for S@L Deeloper#
■ XMLQ@9
% S&alar fun&tionE applied on&e to ea&" ualif*ing do&ument
% )aluate# an X+at" :or X@uer*; e(pre##ion
% Input argument# &an 'e pa##ed into t"e X@uer*:eGgG &olumn name#E &on#tant#E parameter marer#;
% <eturn# a #euen&e of 0E 1 or multiple item# from ea&" do&ument
SELECTXMLK;ER(4%custo$e*+<o%+$e&
ASSIN IN:O AS ):ROM
C;STOMER
XMLCUSTOMER
EID I=7O
6FF6
6FF2
6FF5
1
nameGGG/name
nameGGG/name
GGG
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 27/34
27 © 2010 IBM Corporation
Information Management
S@L/X@uer*> XML Data for S@L Deeloper#
■ S@L@E iterates over a rows in t$e !ustomer ta"e
■ 7or ea!$ rowC (XMLQ@9( is invo#ed % 9"e Hpa##ingH &lau#e 'ind# t"e aria'le HiH to t"e alue of
t"e 4I?FH &olumn of t"e &urrent ro8 % 9"e X@uer* e(pre##ion i# e(e&uted % XML@.)<Q return# t"e re#ult of t"e X@uer* e(pre##ionE
a alue of t*pe XML
SELECTXMLK;ER(4%custo$e*+<o%+$e& ASSIN IN:O AS )
:ROM C;STOMER
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 28/34
2 © 2010 IBM Corporation
Information Management
S@L/X@uer*> XML Data for S@L Deeloper#
■ XMLABL@
%Create# a temporar* S@L ta'le u#ing XML data XMLCUSTOMER
EID I=7O
6FF6
6FF2
6FF5
SELE3T T4
FROM XMLTABLE( !d<2=+>/%0&5%+(?*ML3USTOMERINFO?)-05t&%e'$+&!
COL;MNS ?NAME? VAR3HAR (2") PATH !+.%e!, ?STREET? VAR3HAR (2") PATH !.dd'-t'eet!,
?3IT? VAR3HAR (2") PATH !.dd'-0$t8!) AS T
@05t&%e'$+&
!+$e"o/+ S$t/!%+$e" @.dd' 0&5+t'8B3.+.d.?
!st*eet":ou*t/!%st*eet" !ct6"C9*6!%ct6" @p'&C=t.teA<e't.@-p'&C=
t.te
@p0&de=$pM#T 2A@-p0&de=$p
@-.dd'
@p6&+e t8pe?&'G?
=2J=K#
@-p6&+e@-05t&%e'$+&
=AM@ S9@@ EI
Amir Mai# oung oronto
+o$n Smit$ 7ourt$ Eagary
G G G
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 29/34
0 © 2010 IBM Corporation
Information Management
S@L/X@uer*> XML Data for S@L Deeloper#
■ XML@XISS
%+redi&ate t"at te#t# if an X@uer* e(pre##ion return# a #euen&e
XMLCUSTOMER
EID I=7O
6FF6
6FF2
6FF5
SELE3T 3ID, INFO
FROM *ML3USTOMER WHERE
XMLEXISTS( !d-05t&%e'$+&9+.%e ?&6+ S%$t6?:!
p.$+ INFO . ?d?)
EID I=7O
6FF5
@05t&%e'$+&
!+$e"o/+ S$t/!%+$e"
@.dd' 0&5+t'8B3.+.d.? @t'eetF&5't6@-t'eet
@0$t83..'8@-0$t8
@p'&C=t.teA<e't.@-p'&C=
t.te
@p0&de=$pM#T 2A@-p0&de=$p
@-.dd'
@p6&+e t8pe?&'G?
=2J=K#
@-p6&+e@-05t&%e'$+&
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 30/34
1 © 2010 IBM Corporation
Information Management
XML Inde(e#
■ An index over XML data !an "e used to improve t$e
effi!ien!y of ueries on XML do!uments< %Inde( entrie# 8ill proide a&&e## to node# 8it"in t"e
do&ument '* &reating inde( e*# 'a#ed on XML patterne(pre##ion#G
■
Li#e reationa data t$ey may $ave some !ost< % +erforman&e for I?S)<9E .+DA9) and D)L)9) % Spa&e needed to #tore t"e inde(e#
9eguar Indexes Indexes for XML
Based on !oumnsBased on XML pattern
expressions6 or more !oumns Ony 6 XML !oumn
6 row 6 index #ey
A nodes t$at satisfyt$e XML pattern16 do!ument FC 6 or
more index #eys
B0ree B0ree
CREATE INDEX IDX ONTB(XMLDOC)ENERATE PE ;SIN XMLATTERN%co$p+6%e$p%s*6& AS SKL DO;BLEQ
CREATE INDEX IDX= ONTB(XMLDOC)
ENERATE PE ;SIN XMLATTERN%%d& AS SKL VARCHAR(=0)Q
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 31/34
2 © 2010 IBM Corporation
Information Management
XML Inde(e#> .nder t"e Coer#
■ XML Index !ontains.at$/4aue pairs
■ .at$ en!oded as
.at$ID■ do!ID points to
region !ontainingdo! root node
■ Dire!t su"0do!eve a!!ess pagepage page
XDA
<egion#
Inde(
XML4aues Index
.at$IDC 4aueC Do!IDC =odeIDC<<<C9ID
Integer !$ar xm
GGG GGG
:+at"IDE e*alue; Y :Do&IDE ?odeIDE <o8ID;
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 32/34
© 2010 IBM Corporation
Information Management
Deelopment Support for XML Data
C or CZZ
CBL
C[ and,i#ual Ba#i&
+J+
<u'*
S@L+ro&edure#
aa
+erl
pureXML
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 33/34
- © 2010 IBM Corporation
Information Management
XML % Con&lu#ion
■ =ative XML $ierar!$i!a storage
%?o #"reddingE no CLB#E no BLB# reuired %ptimied for X+A9J and X@uer* :L.! nl*; pro&e##ing
■ 3ig$ performan!e %Superior inde(ing te&"nolog*
%?o par#ing of XML data at uer* runtime■ 7uy integrated XML and reationa pro!essing
%Seamle##l* uer* ariou# t*pe# of data at on&e %?o internal tran#lation of X@uer* into S@L
7/23/2019 2.7 - DB2 pureXML.odp
http://slidepdf.com/reader/full/27-db2-purexmlodp 34/34
Information Management
Information Management Ecosystem PartnershipsIBM Canada Lab
Summer/Fall 2010Questions?
E-mail: imschool@us.ibm.comSubject: “DB2 Academic Wo!sho"#
Recommended