Back to Basics 2017 - Introduction to NoSQL

28

Transcript of Back to Basics 2017 - Introduction to NoSQL

Page 1: Back to Basics 2017 - Introduction to NoSQL
Page 2: Back to Basics 2017 - Introduction to NoSQL

Back to Basics 2017 : Webinar 1

Introduction to NoSQLJoe Drumgoole

Director of Developer Advocacy, EMEAMongoDB

@jdrumgoole

V1.3

Page 3: Back to Basics 2017 - Introduction to NoSQL

Welcome!

Page 4: Back to Basics 2017 - Introduction to NoSQL

4

Course Agenda

Date Time Webinar19-Jan-2017 15:00 GMT Introduction to NoSQL26-Jan-2017 15:00 GMT Your First MongoDB Application02-Feb-2017 11:00 GMT Introduction to Replica Sets09-Feb-2017 11:00 GMT Introduction to Sharding

Page 5: Back to Basics 2017 - Introduction to NoSQL

5

Agenda for Today

• Why NoSQL• The different types of NoSQL database• Detailed overview of MongoDB• Q&A

Page 6: Back to Basics 2017 - Introduction to NoSQL

6

Relational

Expressive Query Language& Secondary Indexes

Strong Consistency

Enterprise Management& Integrations

Page 7: Back to Basics 2017 - Introduction to NoSQL

7

The World Has Changed

Data Risk Time Cost

Page 8: Back to Basics 2017 - Introduction to NoSQL

8

NoSQL

Scalability& Performance

Always On,Global Deployments

FlexibilityExpressive Query Language& Secondary Indexes

Strong Consistency

Enterprise Management& Integrations

Page 9: Back to Basics 2017 - Introduction to NoSQL

9

Nexus Architecture

Scalability& Performance

Always On,Global Deployments

FlexibilityExpressive Query Language& Secondary Indexes

Strong Consistency

Enterprise Management& Integrations

Page 10: Back to Basics 2017 - Introduction to NoSQL

10

Types of NoSQL Database

• Key/Value Stores• Column Stores• Graph Stores• Multi-model Databases• Document Stores

Page 11: Back to Basics 2017 - Introduction to NoSQL

11

Key Value Stores

• An associative array• Single key lookup• Very fast single key lookup• Not so hot for “reverse lookups”

Key Value

12345 4567.3456787

12346 { addr1 : “The Grange”, addr2: “Dublin” }

12347 “top secret password”

12358 “Shopping basket value : 24560”

12787 12345

Page 12: Back to Basics 2017 - Introduction to NoSQL

12

Revision : Row Stores (RDBMS)

• Store data aligned by rows (traditional RDBMS, e.g MySQL)• Reads retrieve a complete row everytime• Reads requiring only one or two columns are wasteful

ID Name Salary Start Date

1 Joe D $24000 1/Jun/1970

2 Peter J $28000 1/Feb/1972

3 Phil G $23000 1/Jan/1973

1 Joe D $24000 1/Jun/1970 2 Peter J $28000 1/Feb/1972 3 Phil G $23000 1/Jan/1973

Page 13: Back to Basics 2017 - Introduction to NoSQL

13

How a Column Store Does it

1 2 3

ID Name Salary Start Date

1 Joe D $24000 1/Jun/1970

2 Peter J $28000 1/Feb/1972

3 Phil G $23000 1/Jan/1973

Joe D Peter J Phil G $24000 $28000 $23000 1/Jun/1970 1/Feb/1972 1/Jan/1973

Page 14: Back to Basics 2017 - Introduction to NoSQL

14

Why is this Attractive?

• A series of consecutive seeks can retrieve a column efficiently• Compressing similar data is super efficient• How do I align my rows? By order or by inserting a row ID• IF you just need a small number of columns you don’t need to

read all the rows• But:

– Updating and deleting by row is expensive• Append only is preferred• Better for OLAP than OLTP

Page 15: Back to Basics 2017 - Introduction to NoSQL

15

Graph Stores

• Store graphs (edges and vertexes)• E.g. social networks• Designed to allow efficient traversal• Optimised for representing connections• Can be implemented as a key value stored with the ability to store

links• MongoDB 3.4 supports graph queries

Page 16: Back to Basics 2017 - Introduction to NoSQL

16

Multi-Model Databases

• Combine multiple storage/access models• Often Graph plus “something else”• Fixes the “polyglot persistence” issue of keeping multiple

independent databases consistent• The “new new thing” in NoSQL Land• MongoDB is a "multi-modal" document store

– Graph– Geo-Spatial– B-tree– Full Text

Page 17: Back to Basics 2017 - Introduction to NoSQL

17

Document Store• Not PDFs, Microsoft Word or HTML• Documents are nested structures created using Javascript Object Notation (JSON)

{ name : “Joe Drumgoole”,title : “Director of Developer Advocacy”,Address : {

address1 : “Latin Hall”,address2 : “Golden Lane”,eircode : “D09 N623”,

}expertise: [ “MongoDB”, “Python”, “Javascript” ],employee_number : 320,location : [ 53.34, -6.26 ]

}

Page 18: Back to Basics 2017 - Introduction to NoSQL

18

MongoDB Documents are Typed

{

name : “Joe Drumgoole”,

title : “Director of Developer Advocacy”,

Address : {

address1 : “Latin Hall”,

address2 : “Golden Lane”,

eircode : “D09 N623”,

}

expertise: [ “MongoDB”, “Python”, “Javascript” ],

employee_number : 320,

location : [ 53.34, -6.26 ]

}

Strings

Nested Document

Array

Integer

Geo-spatial Coordinates

Page 19: Back to Basics 2017 - Introduction to NoSQL

19

MongoDB Understands JSON Documents

• From the very first version it was a native JSON database• Understands and can index the sub-structures• Stores JSON as a binary format called BSON• Efficient for encoding and decoding for network transmission• MongoDB can create indexes on any document field• (We will cover these areas in detail later on in the course)

Page 20: Back to Basics 2017 - Introduction to NoSQL

20

Why Documents?• Dynamic Schema• Elimination of Object/Relational Mapping Layer• Implicit denormalisation of the data for performance

Page 21: Back to Basics 2017 - Introduction to NoSQL

21

Why Documents?• Dynamic Schema• Elimination of Object/Relational Mapping Layer• Implicit denormalisation of the data for performance

Page 22: Back to Basics 2017 - Introduction to NoSQL

22

Aggregation Framework

Page 23: Back to Basics 2017 - Introduction to NoSQL

23

Pipeline Operators• $match

Filter documents

• $projectReshape documents

• $groupSummarize documents

• $outCreate new collections

• $sortOrder documents

• $limit/$skipPaginate documents

• $lookupJoin two collections together

• $unwindExpand an array

Page 24: Back to Basics 2017 - Introduction to NoSQL

24

Instant Start with Compass and AtlasCompass

Atlas

Page 25: Back to Basics 2017 - Introduction to NoSQL

25

Next Webinar – Your First MongoDB Application

• 26th Jan 2017 – 15:00 GMT.• Learn how to build your first MongoDB application

– Create databases and collections– Look at queries– Build indexes– Start to understand performance

• Register at https://www.mongodb.com/webinar/back-to-basics-webinar-series

• Send feedback to [email protected]

Page 27: Back to Basics 2017 - Introduction to NoSQL

Q&A

Page 28: Back to Basics 2017 - Introduction to NoSQL