how to integrate mongodb and sql data with a single rest api

20
1 A Shot of Espresso for Your Enterprise Apps Espresso Logic astest & Easiest Way to Create Backend Services across all data sou

Upload: tyler-band

Post on 31-May-2015

203 views

Category:

Technology


3 download

DESCRIPTION

In this presentation, Espresso Logic demonstrates how to build a RESTful Back-end Service for Mobile Developers. In this first of several in a series, we see how to join SQL tables to NoSQL MongoDB collections into a single, secure, REST API. Combine this with reactive logic and this is the fastest way to deliver mobile systems today.

TRANSCRIPT

Page 1: How to integrate MongoDB and SQL data with a single REST API

Page 1

A Shot of Espresso for Your Enterprise Apps

Espresso Logic

Fastest & Easiest Way to Create Backend Services across all data sources

Page 2: How to integrate MongoDB and SQL data with a single REST API

Espresso Logicpresents

"How to integrate MongoDB and SQL data with a single REST API"

Page 3: How to integrate MongoDB and SQL data with a single REST API

Page 3

Heterogeneous world of data Use Cases for MongoDB & SQL SQL vs Mongo concepts REST as an enterprise standard Building a secure REST Integration Server Creating Custom API endpoints Blending MongoDB with SQL Q&A

Agenda

Page 4: How to integrate MongoDB and SQL data with a single REST API

The Heterogeneous world of data

• SQL• JSON• EDI• CSV• XML• SOAP• ODATA

<book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre></book>

<workspace><atom:title>Default</atom:title><collection href="Categories"><atom:title>Categories</atom:title></collection><collection href="CustomerDemographics"><atom:title>CustomerDemographics</atom:title></collection><collection href="Customers"><atom:title>Customers</atom:title></collection>

Page 5: How to integrate MongoDB and SQL data with a single REST API

SQL vs MongoDB Concepts

SQL Terms/concepts MongoDB Terms/concepts

DATABASE DATABASE

TABLE COLLECTION

ROW DOCUMENT OR BSON DOCUMENT

COLUMN FIELD

INDEX INDEX

TABLE JOINS EMBEDDED DOCUMENTS AND LINKING

PRIMARY KEY PRIMARY KEY

TRANSACTIONS BEGIN, COMMIT/ROLLBACK

NA

SCHEMA NA

Page 6: How to integrate MongoDB and SQL data with a single REST API

Page 6

Language Syntax is different

SQL Terms, Function, Concepts MongoDB Aggregation Operators

WHERE $match

GROUP BY $group

HAVING $match

SELECT $project

ORDER BY $sort

LIMIT $limit

SUM $sum

COUNT $count

JOIN No direct support

Page 7: How to integrate MongoDB and SQL data with a single REST API

Use Cases for MongoDB & SQL

• MongoDB – Storing archival and log

data– Product and Image catalogs– Content Management – BI - Big Data– New Mobile Apps (high

volume reads)

• SQL Database– ACID Transactions– Updates to multiple tables

in single transaction– Financial and Accounting

Page 8: How to integrate MongoDB and SQL data with a single REST API

Use Case for MongoDB and SQL

SQL and MongoDB– Financial and Sales transactions with archived history– Account and Payment Processing– Shopping Carts and Order Entry

Page 9: How to integrate MongoDB and SQL data with a single REST API

REST as an Enterprise standard

http://eval.espressologic.com/rest/sample/demo/v1/

Endpoints: /customer/{id}/employee/{id}/customerWithOrders/product/{id}

{

“@metadata": {"checksum": "A:6c253d56830572ea",

}, "name": "Alpha and Sons", "balance": 0, "credit_limit": 9000 }

Need to build a REST Server

Page 10: How to integrate MongoDB and SQL data with a single REST API

Apache TomcatHibernate (JPA)Spring MVCJDBC and Driver for SQLJersey/Jackson annotationsLogging Library (log4J)Web HostingServlet APIIdentity Security servicesJavaScript runtime engine

Building a secure REST Integration Server

metadata

PropertiesUser & roles definitions, SQL and NoSQL Server connectionsDeclarative (Reactive) RulesRole-based Access ControlSchema ORM ModelSecurity tokensREST API definitionsEvent CodeHard W

ay

Page 11: How to integrate MongoDB and SQL data with a single REST API

The Easy Way (and the fastest)

SQL

name": "Alpha and Sons", "balance": 4484, "MongoOrders": [ { "_id": { "$oid": "53d64c59a32268822c09e994" }, "order_number": 1, "amount_total": 1079, "salesrep_id": 2, "items": [ { "_id": { "$oid": "53d64c38a32268822c09e746" }, "lineitem_id": 1, "product_number": 4, "amount": 600 },

Instant REST API

Page 12: How to integrate MongoDB and SQL data with a single REST API

Espresso Logic Architecture

Complete On-premise VM Appliance or Cloud Managed Service

Page 13: How to integrate MongoDB and SQL data with a single REST API

Step 1 – Connect Existing SQL Database

• SQL Server• Oracle• Azure SQL• MySQL• PostgreSQL• NuoDB• Generic JDBC

SQL

Instant RESTful Endpoints• Tables• Views• Stored Procedures

Page 14: How to integrate MongoDB and SQL data with a single REST API

Step 2- Creating Custom API endpoints

1. Name a new resource

2. Specify the SQL table

(optional)Add sub-documents

Page 15: How to integrate MongoDB and SQL data with a single REST API

Step 3- Blending MongoDB with SQL

Point and Click1. Select Parent SQL2. Add Sub

Document3. Enter MongoDB

Server, database, and collection

4. Specify ‘join’

Test in REST Lab

Page 16: How to integrate MongoDB and SQL data with a single REST API

Step 4 – Customize your API

• Alias Attributes (rename)

• Change format• Select/Project

columns to include• Add new virtual

columns (Row Event)

• Filter/Sort • Limit/Offset

(paging)

Page 17: How to integrate MongoDB and SQL data with a single REST API

Test REST Lab to Blended API

Page 18: How to integrate MongoDB and SQL data with a single REST API

What’s Next

• Adding Authentication to your new REST Server• Setting up users and roles• Assigning security access Roles (Read, Insert,

Update, Delete)• Column and Row level security• Business Logic (Reactive Programming)• Event Model (JavaScript)

Page 19: How to integrate MongoDB and SQL data with a single REST API

Summary

Page 20: How to integrate MongoDB and SQL data with a single REST API

Thank YouQuestions????

http://www.espressologic.com Support: [email protected]: [email protected]