SQL To NoSQL - Top 6 Questions Before Making The Move

38 %
63 %
Information about SQL To NoSQL - Top 6 Questions Before Making The Move

Published on January 29, 2016

Author: dashDB

Source: slideshare.net

1. SQL to NoSQL: Top 6 Questions Glynn Bird Developer Advocate @ IBM @glynn_bird

2. Agenda 2 • Top 6 Questions When Moving to NoSQL 1. Why NoSQL? 2. Rows and Tables Become ... What? 3. Will I Have to Rebuild My App? 4. How do I query data? 5. What's _rev? 6. Does it replicate? • Live Q&A

3. 1. Why NoSQL? 3

4. But, What Is NoSQL, Really? 4 • Umbrella term for databases using non-SQL query languages • Key-Value stores • Column-family stores • Document stores • Graph stores • Some also say "non-relational," because data is not decomposed into separate tables, rows, and columns • It’s still possible to represent relationships in NoSQL • The question is, are these relationships always necessary?

5. NoSQL Document Stores 5 • That's databases like MongoDB, Apache CouchDB™, Cloudant, and Dynamo • Optimized for "semi-structured" or "schema-optional" data • People say "unstructured," but that's inaccurate • Each document has its own structure

6. 6 2.0 multi-node clustering Cloudant Geo Cloudant Query (Mango) Cloudant Search (Lucene) Dashboard

7. Schema Flexibility 7 • Cloudant uses JavaScript Object Notation (JSON) as its data format • Cloudant is based on Apache CouchDB. In both systems, a "database" is simply a collection of JSON documents { "docs": [ { "_id": "df8cecd9809662d08eb853989a5ca2f2", "_rev": "1- 8522c9a1d9570566d96b7f7171623270", "Movie_runtime": 162, "Movie_rating": "PG-13", "Person_name": "Zoe Saldana", "Actor_actor_id": "0757855", "Movie_genre": "AVYS", "Movie_name": "Avatar", "Actor_movie_id": "0499549", "Movie_earnings_rank": "1", "Person_pob": "New Jersey, USA", "Person_id": "0757855", "Movie_id": "0499549", "Movie_year": 2009, "Person_dob": "1978-06-19" } ] }

8. The Cloudant Data Layer 8 • Distributed NoSQL data persistence layer • Available as a fully-managed DBaaS, or managed by you on-premises • Transactional JSON document database with REST API • Spreads data across data centers & devices for scale & high availability • Ideal for apps that require: • Massive, elastic scalability • High availability • Geo-location services • Full-text search • Offline-first design for occasionally connected users

9. Not One DB Server; a Cluster of Servers • A Cloudant cluster • Horizontal scale • Redundant load balancers backed by multiple DB servers • Designed for durability • Saves multiple copies of data • Spreads copies across cluster • All replicas do reads & writes • Access Cloudant over the Web • Developers get an API • Cloudant manages it all behind the scenes 9

10. Horizontal Scaling • Shard across many commodity servers vs. few expensive ones • Performance improves linearly with cost, not exponentially 10

11. 2. Rows and Tables Become ... What? 11

12. ... This! SQL Terms/Concepts database --> table --> row --> column --> materialized view --> primary key --> table JOIN operations --> Document Store Terms/Concepts database bunch of documents document field index/database view/secondary index "_id": entity relations 12

13. Rows --> Documents 13 • Use some field to group documents by schema • Example: "type":"user" or "type":"book" "_id":"user:456" or "_id":"book:9988"

14. Tables --> Databases 14 • Put all tables in one database; use "type": to distinguish • Model entity relationships with secondary indexes • http://wiki.apache.org/couchdb/EntityRelationship

15. 3. How do you query NoSQL 15

16. Indexes and Queries 16 • An "index" in Cloudant is not strictly a performance optimization • Instead, more akin to "materialized view" in RDBMS terms • Index also called a "database view" in Cloudant • Index, then query • You need one before you can do the other • Create index, then query by URL • Can create a secondary index on any field within a document • You get primary index (based on reserved "_id": field) by default • Indexes precomputed, updated in real time • Indexes are updated using incremental MapReduce • You don't need to rebuild the entire index every time a document is changed, added, or deleted • Performant at big-honkin' scale

17. One Cloudant DB, Many Indexes 17 The Cloudant API

18. Cloudant Query 18 curl -X POST 'https://<accountname>.cloudant.com/users/_find' -d '{ "selector": { "age": { "$gt": 25, "$lte": 50 } } }'

19. 4. Will I Have to Rebuild My App? 19

20. Yes 20 By ripping out the bad parts: • Extract, Transform, Load • Schema migrations • JOINs that don't scale

21. Each of My Tables Becomes a Different Type of JSON Document? 21

22. No • Fancy explanation: • Best practice is to denormalize data into 3rd normal form • Or, less fancy: • Smoosh relationships for each entry all together into one JSON doc • Denormalization • Approach to data modeling that shards well and scales well • Works well with data that is somewhat static, or infrequently updated 22 A smooshed and griddled cheese sandwich

23. 23 Example { "_id": "johnsmith@us.ibm.com", "_rev": "12-89e6128fb2d3e2e14559e796b6a71c9d", "name": "John Smith", "title": "Technical Sales Manager", "products": [ "Cloudant", "Information Server"], "languages": [ "English" ], "geolocation": { "coordinates": [ -122.18258, 37.880058 ], "type": "point" }, "address": { "street": "63 Citron knoll", "city": "Orinda", "state": "CA", "country": "USA" } }

24. 5. Does it replicate? 24 { "_id": "johnsmith@us.ibm.com", "_rev": "12-89e6128fb2d3e2e14559e796b6a71c9d", "name": "John Smith", "title": "Technical Sales Manager", "products": [ "Cloudant", "Information Server",], "languages": [ "English" ], "geolocation": { "coordinates": [ -122.18258, 37.880058 ], "type": "point" }, "address": { "street": "63 Citron knoll", "city": "Orinda", "state": "CA", "country": "USA" } }

25. Replication targets 25 • Apache CouchDB • IBM Cloudant • PouchDB (client & server) • Cloudant Sync Libraries

26. 26 www.glynnbird.com • My home page • Cloudant database of articles • Replicated to PouchDB • Appcache for offline first • http://www.glynnbird.com/ 26

27. 6. How do I get data in and out? 27 • Yes • https://cloudant.com/for-developers/migrating-data/ • But every use case is different and everyone’s data is different • Lots of DIY tools on github that could work for you • Cloudant’s Homegrown CSV --> JSON Tools • python: https://github.com/claudiusli/csv-import • Java: https://github.com/cavanaugh-ibm/db-data-loader • Node: https://github.com/glynnbird/couchimport

28. Simple Data Pipe 28 • https://github.com/ibm-cds-labs/pipes

29. Simple Search Service 29 https://developer.ibm.com/clouddataservices /simple-search-service/

30. Glynn Bird Developer Advocate, Cloud Data Services glynn.bird@uk.ibm.com @glynn_bird github.com/glynnbird

31. Legal Slide #1 31 © "Apache", "CouchDB", "Apache CouchDB", "Apache Lucene," "Lucene", and the CouchDB logo are trademarks or registered trademarks of The Apache Software Foundation. All other brands and trademarks are the property of their respective owners.

32. Legal Slide #2 32 © Copyright IBM Corporation 2016 IBM and the IBM Cloudant logo are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at ibm.com/legal/copytrade.shtml

Add a comment

Related pages

SQL to NoSQL: Top 6 Questions Before Making the Move - YouTube

Learn about the key differences between relational databases and JSON document stores like Cloudant, as well as how to dodge the pitfalls of ...
Read more

SQL to NoSQL: Top 6 Questions Before Making the Move ...

Learn what you need to consider when moving from the world of relational databases to a NoSQL document store. Watch this webcast to hear about the key ...
Read more

Webinar Materials: SQL to NoSQL: Top 6 Questions Before ...

Webinar Materials: SQL to NoSQL: Top 6 Questions Before Making the Move. About this webcast: Learn what you need to consider when moving from the world of ...
Read more

Popular Videos - NoSQL & SQL - YouTube

Movies TV Shows News Live Spotlight 360° Video Browse ... From SQL to NoSQL: Top 6 Questions by IBM Cloudant. 58:17. Play next;
Read more

sql - NoSQL DataBases - Stack Overflow

Any system making use of both NoSQL and SQL ... (Scalable SQL) and you do nearly the same SQL as before ... you can move a relational model to noSQL ...
Read more

MongoDB vs MySQL: Comparison Between RDBMS and Document ...

My rundown on MongoDB vs MySQL functions, ... most of the data in our life cannot be stored in SQL format. NoSQL and ... Making an App: 6 Things You Should ...
Read more

10 things you should know about NoSQL databases - TechRepublic

... we'll look at the 10 key aspects of these non-relational NoSQL databases: the top five ... and as databases move into the ... overcome before they can ...
Read more

What's better for your big data application, SQL or NoSQL ...

What's better for your big data application, SQL or NoSQL? ... but NoSQL is making impressive gains and has many ... another SQL implementation on top of ...
Read more

database - When would someone use MongoDB (or similar ...

When would someone use MongoDB ... I've used CouchDB before for three pets ... At what size of data does it become beneficial to move from SQL to NoSQL?
Read more

SQL vs. NoSQL- What You Need to Know - Dataconomy

SQL NoSQL; Data storage: Stored in a relational model, with rows and columns. Rows contain all of the information about one specific entry/entity, and ...
Read more