• No results found

Programming Against Hybrid Databases with Java Handling SQL and NoSQL. Brian Hughes IBM

N/A
N/A
Protected

Academic year: 2021

Share "Programming Against Hybrid Databases with Java Handling SQL and NoSQL. Brian Hughes IBM"

Copied!
31
0
0

Loading.... (view fulltext now)

Full text

(1)

Programming Against Hybrid

Databases with Java

Handling SQL and NoSQL

(2)

Acknowledgements and Disclaimers

Availability. References in this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM

operates.

The workshops, sessions and materials have been prepared by IBM or the session speakers and reflect their own views. They are provided for informational purposes only, and are neither intended to, nor shall have the effect of being, legal or other guidance or advice to any participant. While efforts were made to verify the completeness and accuracy of the information contained in this presentation, it is provided AS-IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this presentation or any other materials. Nothing contained in this presentation is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software.

All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual environmental costs and performance characteristics may vary by customer. Nothing contained in these materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you will result in any specific sales, revenue growth or other results.

© Copyright IBM Corporation 2015. All rights reserved.

U.S. Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

IBM, the IBM logo, ibm.comare trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both. If these and other IBM trademarked terms are marked on their first occurrence in this information with a trademark symbol (® or TM), these symbols indicate U.S. registered or common law trademarks owned by IBM at the time this information was published. Such trademarks may also be registered or common law trademarks in other countries. A current list of IBM trademarks is available on the Web at

•“Copyright and trademark information” at www.ibm.com/legal/copytrade.shtml

(3)

• New Types

• Tables with NoSQL

• Mongo BSON Classes

• JDBC

– Demo database

– SQL and Strings

– New data types (BSON, JSON ???)

• Mongo-Java

(4)

New Type JSON

• JSON (Javascript object notation)

– A lightweight data-interchange format

– Easy to read and write

• Informix server has JSON data type

• JDBC driver has no special support for JSON

– Considered a text string from the driver

– Need 3

rd

party libraries to parse into usable

(5)

New Type BSON

• BSON - a binary form for representing simple

data structures and associative arrays

– Short for Binary JSON

• BSON is efficient for data transfers, space and

traversability

• Most new Informix functions/functionality is

around supporting BSON

(6)

Tables with NoSQL

• Easy to add JSON/BSON types to existing or

new tables

• Create them as a normal columns

(7)

Mongo BSON Classes

• BasicBSONObject

– Base class for holding BSON data

– BSON/Java data can represented as Maps of objects

• Map<String, Object> specifically

– Extends LinkedHashMap

• BasicBSONList

– Represents arrays in BSON structures

– No real value

– Extends List<Object> so casting to a List works just fine

• BSONObject

(8)

Informix JDBC BSON

• Informix JDBC driver has bundled a number of BSON classes

– Subset of Mongo’s org.bson package

– Missing DBObject

(9)

Native Java Mapping

• Informix JDBC driver maps BSON objects

to the IfxBSONObject class

• IfxBSONObject is a hybrid class

– Holds both byte [] representation of a BSON

as well as the Mongo BasicBSONObject

(10)

Demo Database

• Basic Structure for JDBC

(11)

Demo Database (cont)

• A simple data with basic and NoSQL data

types

(12)

Handling NoSQL as Strings

• Using SQL casts we can treat our NoSQL

(13)

SQL Statement with NoSQL as Strings

• Final resulting string is difficult to read and

long

(14)

Querying Data as Strings

• Both JSON and BSON types can be viewed as

Strings

• JSON maps to a native Java String

(15)
(16)
(17)

Demo

(18)

Query Data with Native Types

• JSON is a String

• BSON comes back as an IfxBSONObject

– Informix JDBC UDT for the extended type BSON

(19)

IfxBSONObject

• A UDT, a BSONObject, and a SQLData object

• Allows for easy manipulation of BSON as well

(20)

Processing an IfxBSONObject

• For most operations, you can use the object directly

• Sometimes you might want to convert to a

(21)

Handling Complex BSON

(22)

Handling Complex BSON

(23)

Demo

(24)

Mongo Drivers

• If you work heavily in NoSQL you might prefer

the use of Mongo Drivers

• Requires the setup of the Informix Wire

Listener to understand Mongo protocols

(25)

Index Creation on BSON

• Creating indexes on BSON documents in a

collection is easy

• Basic Mongo create index

(26)

Checking for Indices used

• Mongo API has an explain() method

(27)

Getting Relational data from Mongo

API’s

(28)

Execute Complex SQL via Mongo API’s

• Using SQL pass through you can execute pure

SQL via the Mongo API’s

– secure.sql.passthrough=true

(29)

Demo

(30)
(31)

References

Related documents

Although students are required to submit a thesis approval form that provides a brief description of the proposed research question, methodology, and a detailed timeline and dates

Since the result of fantasy game depends on skill of participant and not sheer chance, and winning or losing of virtual team created by the participant is also independent of outcome

Enable each chapter to invite a sufficient number of PNMs to each event round to match to quota at the conclusion of recruitment.. More than 460 campuses are using

TIC: trauma informed care; TIP: trauma informed practice; ACE: adverse childhood experience; NCTSN: National Child Traumatic Stress Network; ARC: attachment, self‑regulation,

Certifica- tion by the ABHP or by the ABMP in Medical Radiation Protection indicates competence only in radiation safety aspects of radiation oncology, and not in the practice

These putative pathways suggest that hook neurons could either activate the forward command interneurons (Pathway 1 in Fig. 4.1A) to counteract the backward pathway activity

LAI as a SVAT model input parameter was estimated based on the empirical relationship between field measurements, and the vegetation indices NDVI (Nor- malized-Difference

Although earlier single arm phase II trials suggested possible benefits of EGFR antagonists cetuximab and panitumumab either as single agents or in combination with