information on demand using the power of integrated information
Post on 13-Sep-2014
935 views
DESCRIPTION
TRANSCRIPT
![Page 1: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/1.jpg)
© 2005 IBM Corporation
DB2 Express-C 9: Querying XML - It's just data after all...
Kitman [email protected]
http://www-306.ibm.com/software/data/db2/express/
![Page 2: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/2.jpg)
2
Agenda
IBM Supports for the PHP community:
– DB2 Express-C 9: What is it?
– Partnership with Zend
DB2 9 features and tools
PHP development with DB2 9
Building Web Services: SQL/XML and XQuery in DB2 9 pureXML
DB2 Health Web Service – an sample application built with DB2 9 pureXML and open source technologies.
![Page 3: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/3.jpg)
3
DB2 Express-C – If you haven’t heard…
DB2 Express for Open Community.
It isn’t open source, but do you really care?? After all, IT’S FREE!!– Free to download.
– Free to develop on.
– Free to deploy into production.
– Free to bundle with you application.
– In one word, it is “FREE”!
Download site: http://www-306.ibm.com/software/data/db2/express/download.html
Restriction?!? I guess there are a couple:– 2 Processors with 4 GB of RAM, no limit of DISK SIZE!!
Full featured, Enterprise ready, Relation / XML hybrid data store!
When you need to, you pay for support…
Goal Is to build a community of users with DB2 their database of choice.
100,000 downloads since the start of the program (02/2006)
![Page 4: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/4.jpg)
4
DB2 9 – Some of the features…
pureXML: native XML with advanced query support.
Autonomic features:– Automated Maintenance – statistic collection, table reorganization, backup.
– Automated Memory Management (Self-tuning memory management).
– Automated Storage Management.
– Advisors for performance tuning (Configuration and SQL tuning).
Security features– LDAP and kerberos supports.
– LBAC – Label based access control (option)
Row based Compression (option) – 70% saving in storage.
Data Partitioning:– Hash partitioning (DB2 9 ESE with DPF*): evenly distribute data onto multiple server to
take advantage of parallel I/O.
– Range partitioning (Table partition): capability to attach / detach a portion of a large table.
– Multi-Dimensional Clustering: Store data that is related logically in close physical proximity.
* DB2 9 Extended Server Edition with Data Partitioning Feature
![Page 5: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/5.jpg)
5
Demo 0: Checking out DB2 9
Graphical administration interface– Configuration and Design Advisors
– Visual Explain
Developer Workbench
![Page 6: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/6.jpg)
6
DB2 – Performance Tuning
Configuration Advisor:– DB2 is great because it is highly configurable… DB2 is painful because it is highly
configurable…
– 7 simple questions and 2 seconds later… 100+ parameters tuned.
OLTP 32 bit OLTP 64bit Global investment bank A Global investment bank B
Workloads
0
50
100
150
200
250
%-a
ge o
f D
BA
tuned
DBA tuned Advisor as percentage of tuned Default configuration
![Page 7: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/7.jpg)
7
DB2 – Performance Tuning (cont’d)
Visual Explain – helps with manual SQL tuning.
Design Advisor– Helps you with your database design.
– Give the advisor your SQL workload, and it will tell you what database object to create and what benefit to expect.
Performance improvement
0%
20%
40%
60%
80%
100%
120%
Baseline New design
Rel
ativ
e W
orkl
oad
exec
utio
n tim
e
DB2 Design Advisor
Recommendation summary:
20 new indexes
6 new MDC dimensions
4 new partitioning keys
2 new MQTs
84.54% time reduction
6.46x faster
![Page 8: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/8.jpg)
8
DB2 Developer Workbench
Eclipse-based IDE
XML Query Builder
SQL Query Builder
Stored Procedure Builder
![Page 9: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/9.jpg)
9
DB2 for PHP: What IBM is doing for the community?
Express-C program
Zend Core for IBM v1.5
Open source contribution:
– Ibm_db2 – native PHP driver
– PDO_INFORMIX – PDO driver extension for Informix server.
– PDO_IBM – PDO driver extension for DB2 family of product.
Zend Framework partnership
Eclipse-based IDE
App Dev supports:– PHP
– Ruby on Rails
– Perl
– Python
– JDBC
– ODBC
– .NET
DB2 Express Forum
DB2 Express Wiki
![Page 10: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/10.jpg)
10
Setting up PHP with DB2
Zend Core for IBM v1.5, integrated installation: – PHP 5.1.4
– Apache 2
– IBM DB2 Express-C 9
Manual Setup:
– Download and install DB2 Express-C 9 (http://www-306.ibm.com/software/data/db2/express/)
– PHP on Windows:
1. Download ibm_db2 driver from http://pecl4win.php.net/ext.php/php_ibm_db2.dll
2. In the php.ini file, add the following lines:extension=php_ibm_db2.dll
ibm_db2.instance_name=DB2
– PHP on Linux:
1. Download ibm_db2 driver source from http://pecl.php.net/package/ibm_db2
2. Compile…
3. In the php.ini file, add the following lines:extension=ibm_db2.so
ibm_db2.instance_name=db2inst1
![Page 11: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/11.jpg)
11
Demo 1: getting started…
db2_connect
db2_exec
db2_prepare and db2_execute
![Page 12: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/12.jpg)
12
XML is everywhere…Some Industry specific XML format:
FIXML (Financial Information eXchange Markup Language)
– Real time security transaction
MISMO (Mortgage Indust. Standard Maintenance Org’n)
– Mortgage information standard.
ACORD (Association for Cooperative Operations Research and Development)
– Insurance industry standard.
FpML (Financial products Markup Language)
– Standard for trading financial derivative.
![Page 13: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/13.jpg)
13
Financial Data (FIXML)
Buying 1000 Shares of IBM Stock..8=FIX.4.2^9=251^35=D^49=AFUNDMGR^56=ABROKER^34=2^52=20030615-01:14:49^11=12345^1=111111^63=0^64=20030621^21=3^110=1000^111=50000^55=IBM^48=459200101^22=1^54=1^60=2003061501:14:4938=5000^40=1^44=15.75^15=USD^59=0^10=127
New FIXML Protocol
extensiblelower appl development & maintenance cost
Old FIX Protocol
![Page 14: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/14.jpg)
14
Working with these documents…
Standardized, precise way for companies to exchange information.
These document formats are complete. It enables interoperability needed for webservice-based applications.
Necessary evils:
– Documents are HUGE!
– Documents are constantly evolving.
– Partial document retrieval is important.
DB2 Express-C 9 can help.
![Page 15: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/15.jpg)
15
DB2 withXML Support
SQL Person… "I see a world class RDBMS that
also supports XML"
XML Person… “I see a world class XML repository that also
supports SQL"
XML integrated in all facets of DB2!
New XML applications benefit from:• Ability to seamlessly leverage relational investment• Proven Infrastructure that provides enterprise-class capabilities
pureXML in DB2 9
![Page 16: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/16.jpg)
16
pureXML: Interesting features…
XML data type is not a CLOB in your RDMS:
– DB2 9 stores XML data natively in a hierarchical format.
– It’s kind of like a DOM inside your database engine.
– Better support for searching.
XML Indexing:
– XPath pattern indexing.
– Does not require enforcement of a schema
“Schema agnostic” XML column
– Any XML data be stored in a column, as long as it is well formed.
– High performance without tying a schema to a column.
– Validation is the user’s choice.
SQL/XML and XQUERY supports.
![Page 17: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/17.jpg)
17
pureXML: XPath Pattern based Indexing
Will index all documents in a single XML column regardless of schema version.
Indexing using pattern described by standard XPath expression.
Example:CREATE INDEX nativein.country ON nativein.customer(doc) GENERATE KEY USING XMLPATTERN '/customer/phones/phone/countryCode‘ as SQL DOUBLE;
![Page 18: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/18.jpg)
18
pureXML: “Schema Agnostic” XML column
XML column does not require documents to conform to a schema.
Document validation is supported, but not required, on INSERT.
Schema evolution is quick and simple:
– Adding a new element type is significantly simpler than “shredding”.
– Unlike traditional implementation, performance benefits of indexes is not affected.
ACORD uses multiple schema versions at the same time.
Allow “on-demand”, “just-in-time”, “real-time” schema upgrade…
![Page 19: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/19.jpg)
19
Demo 2: Schema Evolution…
Sample v1.0
Sample v1.1
![Page 20: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/20.jpg)
20
pureXML: SQL/XML and XQUERY supports
DB2 9 provides support for:– W3C XQUERY standard (Nov ’06)
– SQL/XML extension to the SQL 99 standard
With these 2 querying standards, you can use manipulate relational and XML data seamlessly and interchangably.
Most XML access only requires a portion of the entire XML document.
Instead of retrieving full XML document and parsing using DOM (or SimpleXML), you can retrieve only the portion you need directly from the database.– Performance gain by eliminating the need of parsing in the php layer.
– Performance gain by reducing network traffic
* The example provided in the following portion will work against the SAMPLE database provided with DB2 Express-C 9
![Page 21: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/21.jpg)
21
pureXML: SQL/XML Support
DB2 function: XMLTABLE– Creating a temporary SQL table using XML data.
(http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.embed.doc/doc/c0023903.htm)
SELECT * FROM XMLTABLE( XMLNAMESPACES (DEFAULT 'http://posample.org'), 'db2-fn:xmlcolumn("CUSTOMER.INFO")/customerinfo' COLUMNS "CID" VARCHAR (50) PATH '@Cid’, "NAME" VARCHAR (50) PATH 'name', "PHONE" VARCHAR (50) PATH 'phone [ @type = "work"]') AS T
![Page 22: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/22.jpg)
22
pureXML: SQL/XML Support
DB2 function: XMLEXISTS– A predicate that test if an XQuery expression returns a sequence.
(http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0022228.htm)
SELECT CID, INFO FROM CUSTOMER WHERE XMLEXISTS( 'declare default element namespace "http://posample.org"; $d/customerinfo [ ./name = "Kathy Smith"]' passing INFO as "d")
![Page 23: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/23.jpg)
23
pureXML: SQL/XML Support
DB2 function: XMLELEMENT / XMLATTRIBUTES– Creating XML segment/document with SQL data.
(http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0511melnyk/#concat )
SELECT XMLELEMENT( NAME "Emp", XMLATTRIBUTES( E.EMPNO, E.FIRSTNME ||' '|| E.LASTNAME AS "name" ) ) AS "XMLData" FROM EMPLOYEE E WHERE E.EDLEVEL = 12
![Page 24: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/24.jpg)
24
pureXML: XQUERY support
db2-fn:sqlquery
– Retrieve an XML document using SQL. Then processing it with an XQuery expression
SELECT * FROM TABLE(values(xmlquery(' declare boundary-space strip; declare default element namespace "http://posample.org"; db2-fn:sqlquery(“ SELECT INFO FROM CUSTOMER WHERE CID = 1001“ )/customerinfo/name' returning sequence))) AS T1
** Reference for DB2 XQuery support:http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.xquery.doc/xqrcontainer.html
![Page 25: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/25.jpg)
25
pureXML: XQUERY support
db2-fn:xmlcolumn
– Retrieve all XML document from an XML column. Then processing it with an XQuery expression
SELECT * FROM TABLE(values(xmlquery(' declare boundary-space strip; declare default element namespace "http://posample.org"; db2-fn:xmlcolumn("CUSTOMER.INFO")/customerinfo[ ./name = "Jim
Noodle"]' returning sequence))) AS T1
![Page 26: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/26.jpg)
26
pureXML: XQUERY support
FLWOR
– One of the most useful XQuery statement.
select * from table (values(XMLQUERY(' declare boundary-space strip; declare default element namespace "http://posample.org"; <product_list> { for $p in db2-fn:xmlcolumn("PRODUCT.DESCRIPTION")/product let $tax := 0.05 where $p/description/price > 5.00 order by $p/pid return ( $p/pid, $p/description/name, $p/description/price, <tax> $p/description/price * $tax </tax> ) } </product_list>' RETURNING SEQUENCE))) as t1
![Page 27: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/27.jpg)
27
Demo 3: SQL/XML & XMLQUERY
1. Using XMLTABLE to return XML data as a Result Set
2. JOIN with XMLTABLE
3. Returning SQL data in a larger XML document.
![Page 28: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/28.jpg)
28
Demo 4: Building an Application.
DB2 Health Monitoring Service:
– PHP based web service using SQL/XML to retrieve data from DB2 9 database.
– SimpleXML & DOM for some post processing.
– WSDL-SOAP services using NuSOAP
DB2 Monitoring GUI:
– DOJO AJAX toolkit
![Page 29: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/29.jpg)
29
Health Monitoring Service – SQL/XML Example…
DB2 health monitor reports database “health” through Table Functions.
Using DB2 9 XML support, SQL data from these functions are converted to XML documents served up as a web service.
SELECT XMLSERIALIZE( CONTENT XMLELEMENT( NAME "HealthAlert", XMLATTRIBUTES( t.HI_ID as "hiIdentifier", t.HI_ALERT_STATE_DETAIL as "hiAlertState", t.HI_VALUE as "hiValue", t.HI_TIMESTAMP as "hiTimestamp" ), XMLELEMENT( NAME "DB2_Object", XMLATTRIBUTES( t.DB_NAME as "name", 'database' as "type" ) ), XMLELEMENT( NAME "HiAdditionalInfo", t.HI_ADDITIONAL_INFO ), XMLELEMENT( NAME "HiFormulaValue", t.HI_FORMULA ) ) AS CLOB (32000) )AS "ALERT"FROM table (health_db_hi('', -1)) as t
![Page 30: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/30.jpg)
30
![Page 32: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/32.jpg)
32
![Page 33: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/33.jpg)
33
![Page 34: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/34.jpg)
34
![Page 35: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/35.jpg)
35
![Page 36: Information On Demand Using the Power of Integrated Information](https://reader033.vdocuments.net/reader033/viewer/2022051411/5413c0038d7f7294698b46ee/html5/thumbnails/36.jpg)
36
Last minutes notes… borrowing Wez’s “telephone call” analogy
I have a PDO related question and I want to ask Wez…
So I can up my friend… ring-ring…