Introduction to MongoDB Kristina Chodorow kristina@mongodb.org - - PowerPoint PPT Presentation

introduction to mongodb
SMART_READER_LITE
LIVE PREVIEW

Introduction to MongoDB Kristina Chodorow kristina@mongodb.org - - PowerPoint PPT Presentation

Introduction to MongoDB Kristina Chodorow kristina@mongodb.org Application PHP Apache Database Linux Application PHP IIS Windows Application PHP Apache Linux Application PHP Apache Linux Application PHP Apache Linux


slide-1
SLIDE 1

Kristina Chodorow kristina@mongodb.org

Introduction to MongoDB

slide-2
SLIDE 2
slide-3
SLIDE 3

Application PHP Linux Database Apache

slide-4
SLIDE 4

Application PHP Windows IIS

slide-5
SLIDE 5

Application PHP Linux Apache

slide-6
SLIDE 6

Application PHP Linux Apache

slide-7
SLIDE 7

Application PHP Linux Apache

slide-8
SLIDE 8

Application PHP Linux Apache

The world's most popular open source database

slide-9
SLIDE 9

Application PHP Linux Apache

The world's most advanced open source database

slide-10
SLIDE 10
slide-11
SLIDE 11

databases

contain tables contain rows

server

slide-12
SLIDE 12

databases

contain tables contain rows

schema server

slide-13
SLIDE 13

databases

contain tables contain rows

joins schema server

slide-14
SLIDE 14

databases

contain tables contain rows

joins schema server

slide-15
SLIDE 15
slide-16
SLIDE 16
slide-17
SLIDE 17
slide-18
SLIDE 18
slide-19
SLIDE 19

Application Perl Linux Apache

slide-20
SLIDE 20

getting started

slide-21
SLIDE 21

www.mongodb.org

slide-22
SLIDE 22

$ mysqld

slide-23
SLIDE 23

$ mongod

slide-24
SLIDE 24

$ mysql

slide-25
SLIDE 25

$ mongo

slide-26
SLIDE 26

$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help >

slide-27
SLIDE 27

$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help > db

slide-28
SLIDE 28

$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help > db test >

slide-29
SLIDE 29

$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help > db test >

slide-30
SLIDE 30

$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help > db test > table = db.foo

slide-31
SLIDE 31

server

slide-32
SLIDE 32

databases server

slide-33
SLIDE 33

databases

contain tables

server

slide-34
SLIDE 34

databases

contain tables

server

slide-35
SLIDE 35

databases

contain tables

server

slide-36
SLIDE 36

databases

contain rows

server

contain tables

slide-37
SLIDE 37

databases

contain rows

server

contain tables

slide-38
SLIDE 38

databases

contain rows

server

contain tables

slide-39
SLIDE 39

databases

contain rows

server

contain tables

schema

slide-40
SLIDE 40

databases

contain rows

server

contain tables

schema joins

slide-41
SLIDE 41

databases

contain collections contain documents

server

slide-42
SLIDE 42

$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help > db test > collection = db.foo

slide-43
SLIDE 43

$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help > db test > collection = db.foo

slide-44
SLIDE 44

> doc = { ... "name" : "kristina", ... "contact info" : { ... "twitter" : "@kchodorow", ... "email" : "kristina@10gen.com" ... }, ... "friends" : 400232, ... "pic" : BinData(...) ... "member since" : new Date()}

slide-45
SLIDE 45

> db.foo.insert(doc)

slide-46
SLIDE 46

> db.foo.findOne({"name" : "kristina"});

slide-47
SLIDE 47

> db.foo.findOne({"name" : "kristina"}) > db.foo.findOne({ ... "contact.twitter" : "@kchodorow"})

slide-48
SLIDE 48

> db.foo.findOne({"name" : "kristina"}) > db.foo.findOne({ ... "contact.twitter" : "@kchodorow"}) > db.foo.find({ ... "member since" : { ... "$gt" : yesterday, ... "$lt" : today ... }})

slide-49
SLIDE 49

> db.foo.findOne({"name" : "kristina"}) > db.foo.findOne({ ... "contact.twitter" : "@kchodorow"}) > db.foo.find({ ... "member since" : { ... "$gt" : yesterday, ... "$lt" : today ... }}).sort({friends : 1}).limit(10). ... skip(100)

slide-50
SLIDE 50

db.people.update( {name : "kristina"},

slide-51
SLIDE 51

db.people.update( {name : "kristina"}, {$set :

slide-52
SLIDE 52

db.people.update( {name : "kristina"}, {$set : {"contact.website" : "snailinaturtleneck.com" }});

slide-53
SLIDE 53

> db.pageviews.update( {url : "example.com"}, {$inc : {pageviews : 1}}, true)

slide-54
SLIDE 54
slide-55
SLIDE 55
slide-56
SLIDE 56

some features

slide-57
SLIDE 57

I suddenly have a deep love for stored procedures

slide-58
SLIDE 58

I suddenly have a deep love for stored procedures

slide-59
SLIDE 59

> db.system.js.insert({ "_id" : "x", "value" : 3}); > db.system.js.insert({ "_id" : "y", "value" : 4}); > db.eval("return x+y")

slide-60
SLIDE 60

> db.system.js.insert({_id : "log", ... value : function(msg, level) { ... var date = "[" + new Date() + "] "; ... var lvl = level ? level+" " : ""; ... print(date + lvl + msg); ... }})

slide-61
SLIDE 61

> db.eval("log('all your base are belong to us', 'FATAL');");

slide-62
SLIDE 62

> db.eval("log('all your base are belong to us', 'FATAL');"); [Fri May 19 18:34:57] FATAL all your base are belong to us

slide-63
SLIDE 63
slide-64
SLIDE 64
slide-65
SLIDE 65

J J J J J J J J J

slide-66
SLIDE 66
slide-67
SLIDE 67

capped collections

slide-68
SLIDE 68

indexes

slide-69
SLIDE 69

geospatial indexes

slide-70
SLIDE 70
slide-71
SLIDE 71

MapReduce

slide-72
SLIDE 72

what did we leave out?

slide-73
SLIDE 73
slide-74
SLIDE 74

I say, we should get a mainframe, old chap. Harumph.

slide-75
SLIDE 75
slide-76
SLIDE 76
slide-77
SLIDE 77
slide-78
SLIDE 78

are you practicing safe data storage?

slide-79
SLIDE 79
slide-80
SLIDE 80

Insert this. Okay, got it. Phew, my data's safe.

slide-81
SLIDE 81

Write this to disk All over it! I know better than he does, I'll just let this sit in a buffer for a while.

slide-82
SLIDE 82
slide-83
SLIDE 83

? I have no idea what you're talking about.

slide-84
SLIDE 84

trust no one!

...trust a bunch of ones. Mostly.

slide-85
SLIDE 85

prod1.example.com prod2.example.com

slide-86
SLIDE 86

prod1.example.com prod2.example.com

slide-87
SLIDE 87

prod1.example.com prod2.example.com

slide-88
SLIDE 88

prod1.example.com prod2.example.com

slide-89
SLIDE 89
slide-90
SLIDE 90

prod1.example.com prod2.example.com

slide-91
SLIDE 91

prod1.example.com prod2.example.com

slide-92
SLIDE 92

prod1.example.com

?

prod2.example.com

slide-93
SLIDE 93

prod2.example.com prod1.example.com

slide-94
SLIDE 94

prod2.example.com prod1.example.com

?

slide-95
SLIDE 95

prod2.example.com prod1.example.com

slide-96
SLIDE 96

prod2.example.com prod1.example.com

slide-97
SLIDE 97

primary secondary passive secondary

slide-98
SLIDE 98

secondary passive secondary

My priority is 2 My priority is 1

slide-99
SLIDE 99

primary passive secondary

slide-100
SLIDE 100

secondary passive secondary

I'm 5 minutes behind the master I'm 3 seconds behind the master

slide-101
SLIDE 101

secondary passive primary

slide-102
SLIDE 102

passive

I'll still take reads.

slide-103
SLIDE 103
slide-104
SLIDE 104
slide-105
SLIDE 105
slide-106
SLIDE 106
slide-107
SLIDE 107
  • kay
slide-108
SLIDE 108

?

slide-109
SLIDE 109

make sure two slaves have this

slide-110
SLIDE 110
slide-111
SLIDE 111
slide-112
SLIDE 112
slide-113
SLIDE 113

all set

slide-114
SLIDE 114
slide-115
SLIDE 115
slide-116
SLIDE 116
slide-117
SLIDE 117
slide-118
SLIDE 118
slide-119
SLIDE 119
slide-120
SLIDE 120

scaling

slide-121
SLIDE 121
slide-122
SLIDE 122

(rdbms)

slide-123
SLIDE 123

U - Z K - O A - E F - J P - T

slide-124
SLIDE 124

U - Z K - O A - E F - J P - T

I want Mark through Sarah.

slide-125
SLIDE 125

U - Z K - O A - E F - J P - T

slide-126
SLIDE 126

U - Z K - O A - E F - J P - T

slide-127
SLIDE 127

U - Z K - O A - E F - J P - T

Insert Linus

slide-128
SLIDE 128

U - Z K - O A - E F - J P - T

Insert Linus

slide-129
SLIDE 129

U - Z K - O A - E F - J P - T

slide-130
SLIDE 130

$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help >

slide-131
SLIDE 131

$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help > db.foo.insert({x:1})

slide-132
SLIDE 132

thank you!

@kchodorow http://www.snailinaturtleneck.com