Relational to NoSQL: Getting started from SQL Server

51
Relational to NoSQL: Getting started from SQL Server Shane Johnson Sr. Product Marketing Manager Couchbase

Transcript of Relational to NoSQL: Getting started from SQL Server

Page 1: Relational to NoSQL: Getting started from SQL Server

Relational to NoSQL:Getting started from SQL Server

Shane JohnsonSr. Product Marketing Manager

Couchbase

Page 2: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 2

Todayā€™s agenda

Ā§ Why NoSQL?Ā§ Identifying the right applicationĀ§ Modeling your dataĀ§ Accessing your dataĀ§ Installing and scaling your databaseĀ§ Monitoring and managing your deploymentĀ§ Q & A

Page 3: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 3

About the speakers ā€“ Shane Johnson

Shane JohnsonSenior Product Marketing ManagerCouchbase (since Dec 2013)

Experience:- Proud Red Hatter

- Consulting (Architect)- Transitioned to Marketing (Technical Manager)- Passionate about Open Source

- Expertise- Java and Distributed Systems

Page 4: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 4

Whatā€™s Couchbase?

Couchbase is the company behind Couchbase Server & Couchbase Mobile

ā€¢ Open source JSON databaseā€¢ Founded 2010ā€¢ 500+ enterprise customers globally

Some of our customers:

Couchbase Server can be deployed as:

Document database Key-value store Distributed cache

Page 5: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 5

What is NoSQL?

Ā§ No SQL? No.Ā§ Not only SQL? Not really.Ā§ Non relational? Yes.

Ā§ Distributed (most)ā€“ Scaled out, not upā€¢ Elasticity and commodity hardware

ā€“ Partitioned and replicatedā€¢ Scalability, performance, availability

Ā§ Schema-less (most)ā€“ Flexible modelā€“ JSON (some)

Page 6: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 6

Who is using NoSQL?

Enterprises are adopting NoSQL for mission critical applications

Media & Publishing eCommerce Hospitality

Page 7: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 7

Who is using NoSQL?

Ā§ Gannett, publisher of USA Today and 90+ media properties, replaced relational database tech- nology with NoSQL to power its digital publishing platform.

Ā§ Marriott deployed NoSQL to modernize its hotel reservation system that supports $38 billion in annual bookings.

Ā§ FHLBank Topeka leverages NoSQL on top of SQL Server to speed up access to customer financial data for its 770 member banks

Ā§ Cars.com, with over 30 million visits per month, replaced SQL Server with NoSQL to store customer and vehicle data

Ā§ Vente-privee.com improved the customer experience of its 18 million members by replacing SQL Server with NoSQL for better performance

Page 8: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 8

Why are they using NoSQL?

Technology Drivers

Ā§ Customers are going onlineĀ§ The Internet is connecting everythingĀ§ Big Data is getting biggerĀ§ Applications are moving to the cloudĀ§ The world has gone mobile

Technical Needs

Ā§ Develop with agilityā€“ Flexibility + Simplicityā€“ Easier + Faster

Ā§ Operate at any scaleā€“ Elasticity + Availabilityā€“ Performance at scaleā€“ Always-on, global deployment

Business Needs

Ā§ Innovate and competeā€“ Faster time to marketā€“ Reduced costs (operational + hardware)ā€“ Increased revenue

Page 9: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 9

Why migrate from SQL Server?

Ā§ Easier to scale3 nodes to 100s, 1 data center to many, commodity hardware

Ā§ Better performanceintegrated caching, memory-optimized indexes, memory-based replication

Ā§ Up to 40x lower costopen source, subscription-based, per instance (not per core)

Ā§ Cross-platformruns on Windows or Linux (Red Hat, Ubuntu, Debian, etc)

Ā§ Greater agilityJSON-based data model, SQL-based query language

Page 10: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 10

How do you get started?

Ā§ Identify the right applicationĀ§ Model your dataĀ§ Access your dataĀ§ Install and scale your databaseĀ§ Monitor and manage your deployment

Page 11: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 11

Identifying the right application

Have one or more of the following characteristics or requirements:

Iterate fasterSend and receive JSONProvide low latency at any throughputSupport many concurrent users

Supports users anywhere and everywhereBe available 24x7Store terabytes of dataRead and write to multiple data centers

Service

RDMBS

Service Service

NoSQL

ApplicationExamples:

Ā§ High performance, high availability caching serviceĀ§ Small, independent application with a narrow scopeĀ§ Logical or physical service within a large applicationĀ§ Global service that powers multiple applications

Page 12: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 12

Concepts: Terminology

Relational (SQL Server) NoSQL (Couchbase)

Failover Cluster Cluster

Availability Group Cluster

Database Bucket

Table Bucket

Row (Tuple) Document (JSON)

Primary Key Object ID

IDENTITY Counter

Indexed View View

SQL N1QL

Page 13: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 13

Model your data

Page 14: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 14

Modeling your data: Fixed vs. self-describing schema

Page 15: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 15

Modeling your data: The flexibility of JSON

Same document type,Different fields

ā€¢ Different typesā€¢ Optionalā€¢ On-demand

Tip: Add a version field to track changes.

{ā€œdocTypeā€: ā€œuserā€, ā€œdocVersionā€: ā€œ1ā€, ā€¦}{ā€œdocTypeā€: ā€œuserā€, ā€œdocVersionā€: ā€œ2ā€, ā€¦}

Page 16: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 16

Modeling your data: Changing the data model

Relational database

ā€¢ Modify the database schemaā€¢ Modify the application code (e.g. Java)ā€¢ Modify the interface (e.g. HTML5/JS)

Document database

ā€¢ Modify the interface (e.g. HTML5/JS)

Page 17: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 17

Modeling your data: Object IDs

Best Practices

ā€¢ Natural Keysā€¢ Human Readableā€¢ Deterministicā€¢ Semantic

Examples

ā€¢ author::shaneā€¢ author::shane::blogsā€¢ blog::nosql_fueled_hadoopā€¢ blog::nosql_fueled_hadoop::comments

What about identity columns?

1. Document<Long> nextAuthorIdDoc= bucket.counter(ā€œauthorIdCounterā€, 1);2. Long nextAuthorId = nextAuthorIdDoc.content();3. String authDocId = ā€œauthor::ā€ + nextAuthorId; // author::101

Tip: Increment the counter by 10, 20, etc. instead of doing it for every insert.

Page 18: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 18

Modeling your data: Relationships

Author

Blog (FK)Blog (FK)

Comment (FK) Comment (FK)

Author (FK x2)

BlogBlog (FK x2)

Comment Comment

Bottom up Top down

Page 19: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 19

Modeling your data: Relationships

Page 20: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 20

Modeling your data: Strategies and best practices

Ifā€¦ Thenā€¦

Relationship is one-to-one or one-to-many Store related data as nested objects

Relationship is many-to-one or many-to-many Store related data as separate documents

Data reads are mostly parent fields Store children as separate documents

Data reads are mostly parent + child fields Store children as nested objects

Data writes are mostly parent or child (not both) Store children as separate documents

Data writes are mostly parent and child (both) Store children as nested objects

Page 21: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 21

Modeling your data: Strategies and best practices

Ā§ Are they a lot of concurrent writes, continuous updates?Ā§ Store children as separate documents

BlogĀ§ Thread

Ā§ CommentĀ§ Comment

Ā§ ThreadĀ§ CommentĀ§ Comment

Blog

{ā€œdocTypeā€: ā€œblogā€,

ā€œauthorā€: ā€œauthor::shaneā€,ā€œtitleā€: ā€œCouchbase Winsā€,ā€œthreadsā€: [

ā€œblog::couchbase_wins::threads::001ā€,ā€œblog::couchbase_wins::threads::002ā€

}

Thread

{ā€œdocTypeā€: ā€œthreadā€,

ā€œcommentsā€: [{

ā€œvisitorā€: ā€œBrendan Bondā€,

ā€œtextā€: ā€œThis blog is amazing!ā€ā€œrepliesā€: [

{

ā€œuserā€: ā€œDustin Johnsonā€,ā€œtextā€: ā€œNo, it is not.ā€

}]

}}

Page 22: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 22

Access your data

Page 23: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 23

Accessing your data: Options

Key-Value(CRUD)

N1QL(Query)

Views(Query)

Documents

Indexes MapReduce

Full Text(Search)

Geospatial(Search)

Weā€™ll focus on these three for now.

Indexes MapReduce

Page 24: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 24

Accessing your data: Connecting to the database

Ā§ Access data via topology-aware smart clientsĀ§ Maintains an up-to-date cluster mapĀ§ Communicates directly with database nodes ā€“ no proxies, no routers, etc.

Ā§ Available for Java, Node.js, PHP, .NET, Python, C, Go, and moreĀ§ With standard, certified JDBC/ODBC drivers (if you want to)

Page 25: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 25

Accessing your data: Domain objects vs. document objects

* JSON serialization via Boon.

Working with document objects requires less code, provides more flexibility.

Page 26: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 26

Accessing your data: Key-value operations ā€“ referenced data

Page 27: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 27

Accessing your data: Key-value operations ā€“ nested data

Page 28: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 28

Accessing your data: Subdocument operations

Page 29: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 29

Accessing your data ā€“ N1QL queries: Capabilities

Feature SQL N1QL

JOIN āœ” āœ”

TRANSFORM āœ” āœ”

FILTER āœ” āœ”

AGGREGATE āœ” āœ”

SORT āœ” āœ”

SUBQUERIES āœ” āœ”

PAGINATION āœ” āœ”

OPERATORS āœ” āœ”

FUNCTIONS āœ” āœ”

Page 30: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 30

Accessing your data: N1QL queries ā€“ referenced data

Page 31: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 31

Accessing your data: N1QL queries ā€“ nested data

Page 32: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 32

Accessing your data: N1QL queries ā€“ CRUD

Page 33: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 33

Accessing your data: LINQ

_context.Query<Users>().Where(u => u.status == ā€œPlatinumā€)

from user in _context.Query<Users>()join account in _context.Query<Account>()on user.accountId equals N1QlFunctions.Key(account) into userGroupfrom accounts in userGroup.DefaultIfEmpty()where (account.type == ā€œVisaā€ || account.type== ā€œMasterCardā€)select new { firstName = user.firstName, lastName = user.LastName };

from user in _context.Query<Users>()join address in _context.Query<Address>()on user.addresses.shipping.addressId equals N1QlFunctions.Key(address) into addressGroupfrom address in addressGroup.DefaultIfEmpty()where address.state == ā€œCAā€select new { firstName = user.firstName, lastName = user.LastName };

Page 34: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 34

Accessing your data: N1QL queries ā€“ indexes

Simple

Compound

Functional

Partial

Page 35: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 35

Accessing your data: Views

What if indexed views worked great with write intensive workloads?

And you could use COUNT, ORDER BY, and everything elseā€¦

Page 36: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 36

Accessing your data: Views

COUNT ?!?

Page 37: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 37

Accessing your data: Views ā€“ Incremental MapReduce

Page 38: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 38

Accessing your data: Views ā€“ queries

Page 39: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 39

Accessing your data: Strategies and best practices

Concept Strategies & Best Practices

Key Value Operations provide the best possible performance

ā€¢ Create an effective key naming strategyā€¢ Create an optimized data model

Incremental MapReduce (Views) are well suited to aggregation

ā€¢ Ideal for large data sets, the entire data setā€¢ Can be used to create complex secondary

indexes

N1QL queries provide the most flexibility ā€“everything else

ā€¢ Query data regardless of how it is modeledā€¢ Remember to create indexes, leverage

covering indexes where possible

Page 40: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 40

Install and scaling your database

Page 41: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 41

Installing and scaling your database

Admin screenshot ā€“ add node

1. Download2. Install3. Configure4. Cluster / Scale5. Rebalance

Page 42: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 42

Installing and scaling your Couchbase database: XDCR

Ā§ Multiple Data CentersĀ§ Cluster per data centerĀ§ Replicate between clustersĀ§ Unidirectional / bidirectionalĀ§ Master / MasterĀ§ Local reads and writesĀ§ RingĀ§ Hub-and-spokeĀ§ MeshĀ§ CombinationĀ§ Built-in

Page 43: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 43

Managing and monitoring your deployment

Page 44: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 44

Managing and monitoring your deployment

Ā§ Configurationā€“ Authentication and authorizationā€“ Auditing

Ā§ Monitoringā€“ View and collect log information

Ā§ Toolingā€“ cbbackup & cbrestoreā€“ cbcollect_info & cbdstatsā€“ cbqā€“ cbtransferā€“ and moreā€¦

Ā§ Management, monitoring, and configuration ā€“ Cluster / node / bucket / viewsā€“ Cross data center replication (XDCR)ā€“ Database performance, network

utilization, resource utilization

Ā§ Tasksā€“ Add and remove nodesā€“ Failover nodesā€“ Rebalance cluster

* Web, REST API, and CLI

Page 45: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 45

Where to go next?

Conduct a Successful Proof of Concept

1. Select a use case and application2. Define the success criteria3. Understand the data4. Identify the access patterns5. Review the architecture

Measure your Return on Investment

Ā§ Greater agility?Ā§ Faster time to market?Ā§ Easier scalability?Ā§ Better performance?Ā§ Better availability?Ā§ Lower costs?

Page 46: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 46

Youā€™re just in time

Couchbase Server 4.5 Beta

Easier, more efficient queryingIntegrated query editorIndexed joinsIntegrated full-text searchReady your own writes

Simpler, more advanced data accessPartial updates, reads, etc.

www.couchbase.com/next

Faster, more powerful indexingMemory-optimized indexesArray indexingCircular reuse

Better, more comprehensive adminQuery monitoringFaster backup and restoreX.509 certificatesRole-based access control

Page 47: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 47

Query Workbench: ad-hoc queries

Page 48: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 48

Query Workbench: schema browser

Page 49: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 49

Questions?

Page 50: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 50

WANT TO LEARN MORE?

Getting Started guide:http://www.couchbase.com/get-started-developing-nosql

Download Couchbase software:http://www.couchbase.com/nosql-databases/downloads

Free Online Traininghttp://training.couchbase.com/online

ā€œHow to Get Startedā€ White Paperhttp://www.couchbase.com/binaries/content/assets/us/product/couchbase-server-

4.0/sql_servertonosql.pdf

Page 51: Relational to NoSQL: Getting started from SQL Server

Ā©2015 Couchbase Inc. 51

Thank you.