SlideShare une entreprise Scribd logo
1  sur  53
Télécharger pour lire hors ligne
#MongoDBDays

Building your first app;
an introduction to MongoDB
Thomas Rückstieß
Technical Services Engineer, MongoDB
Notes to the Presenter
•  Themes for this presentation:
• 

First presentation in the conference. Keep it fun

• 

User is likely brand new to MongoDB and comes
from traditional relational background

• 

This is an introduction. Don't go deep.. Introduce
concepts and refer to later presentations that build
on these concepts.
What is MongoDB?
MongoDB is a ___________ database
•  Document
•  Open source
•  High performance
•  Horizontally scalable
•  Full featured
Document Database
•  Not for .PDF & .DOC files
•  A document is essentially an associative array

with key/value pairs (possibly nested)
{
username : “thomas.r",
num_logins : 39,
last_login : ISODate("2013-10-08T16:46:21Z"),
permissions : ["read", "write", "list", "admin"],
company : {
name : "MongoDB, Inc."
location : "Sydney, Australia"
}
}
Open Source
•  MongoDB is an open source project
•  On GitHub
•  Licensed under the AGPL
•  Started & sponsored by 10gen (now MongoDB, Inc.)
•  Commercial licenses available
•  Contributions welcome
High Performance
•  Written in C++
•  Extensive use of memory-mapped files

i.e. read-through write-through memory caching.
•  Runs nearly everywhere
•  Data serialized as BSON (fast parsing)
•  Full support for primary & secondary indexes
•  Document model = less work
Horizontally Scalable

Shard 1

Shard 2

Shard 3

Horizontally Scalable

Shard N
Full Featured
•  Ad Hoc queries
•  Real time aggregation
•  Rich query capabilities
•  Strongly consistent
•  Geospatial features
•  Support for most programming languages
•  Flexible schema
Scalability & Performance
Scalability & Performance

Database Landscape
Memcached
MongoDB

RDBMS

Depth of Functionality
mongodb.org/downloads
Running MongoDB
$ tar –z xvf mongodb-osx-x86_64-2.4.x.tgz
$ cd mongodb-osx-i386-2.4.4/bin
$ mkdir –p /data/db
$ ./mongod
Mongo Shell
$ mongo
MongoDB shell version: 2.4.4
connecting to: test
> db.test.insert( { text: 'Welcome to MongoDB’ } )
> db.test.find().pretty()
{
"_id" : ObjectId("51c34130fbd5d7261b4cdb55"),
"text" : "Welcome to MongoDB"
}
Document Database
Terminology
RDBMS

MongoDB

Table, View

➜

Collection

Row

➜

Document

Index

➜

Index

Join

➜

Embedded Document

Foreign Key

➜

Reference

Partition

➜

Shard
Let’s Build a Blog
First step in any application is

Determine your entities
Entities in our Blogging System
•  Users
•  Articles
•  Comments
•  Tags
•  Categories ( ? )
In a relational database app
We would start by doing schema design
Typical (relational) ERD
Category
·Name
·URL

User
·Name
·Email address

Article
·Name
·Slug
·Publish date
·Text

Comment
·Comment
·Date
·Author

Tag
·Name
·URL
Relational schema design
•  Large ERD Diagrams
•  Complex “create table” statements
•  ORMs to map tables to objects
•  Tables just to join tables together
•  Lots of revisions until we get it right
In a MongoDB based app
We start building our app
and let the schema evolve
MongoDB ERD
Article

User
·Name
·Email address

·Name
·Slug
·Publish date
·Text
·Author

Comment[]
·Comment
·Date
·Author

Tag[]
·Value

Category[]
·Value
Working With MongoDB
The Shell
Start with an object
(or array, hash, dict, etc)
> var user = {
username: ’thomas.r',
first_name: ’Thomas',
last_name: ’Rückstieß',
}
Insert the Record
> db
test
> use blog
switched to db blog
// syntax is “db.<collection>.<command>”
> db.users.insert( user )

No db/collection creation necessary
Retrieve the Record again
// get one document (don’t care which one)
> db.users.findOne()
{
"_id" : ObjectId("50804d0bd94ccab2da652599"),
"username" : ”thomas.r",
"first_name" : ”Thomas",
"last_name" : ”Rückstieß"
}
_id
•  _id is the primary key in MongoDB
•  Any unique immutable value could be used
•  Automatically created as an ObjectId if not provided
•  Automatically indexed
ObjectId
•  ObjectId is a special 12 byte value
•  Guaranteed to be unique across your cluster
•  ObjectId("50804d0bd94ccab2da652599")

ts

mac pid

inc
Creating a Blog Article
> db.articles.insert( {
title: ‘Hello World’,
body: ‘This is my first blog post’,
date: new Date(‘2013-06-20’),
username: ‘thomas.r’,
tags: [‘adventure’, ‘mongodb’],
comments: [ ]
})
Finding the Article
> db.articles.find().pretty()
{
"_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"),
"title" : "Hello World",
"body" : "This is my first blog post",
"date" : ISODate("2013-06-20T00:00:00Z"),
"username" : ”thomas.r",
"tags" : [
"adventure",
"mongodb"
],
"comments" : [ ]
}
Finding the Article
> db.articles.find(
{ _id : ObjectId("51c3bafafbd5d7261b4cdb5a") } )
.pretty()
{
"_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"),
"title" : "Hello World",
"body" : "This is my first blog post",
"date" : ISODate("2013-06-20T00:00:00Z"),
"username" : ”thomas.r",
"tags" : [
"adventure",
"mongodb"
],
"comments" : [ ]
}
Querying An Array
> db.articles.find( { tags : 'adventure’ } ).pretty()
{
"_id" : ObjectId("51c3bcddfbd5d7261b4cdb5b"),
"title" : "Hello World",
"body" : "This is my first blog post",
"date" : ISODate("2013-06-20T00:00:00Z"),
"username" : ”thomas.r",
"tags" : [
"adventure",
"mongodb"
],
"comments" : [ ]
}
Using Update to Add a Comment
// the syntax is: “ update ( what, how ) “
> db.articles.update(
{ _id: ObjectId("51c3bcddfbd5d7261b4cdb5b”) },
{ "$push" : {
"comments" : {
"name" : "Steve Noname",
"comment" : "Awesome Post"
}
}
)
Article with Comment Embedded
> db.articles.find( { username: “thomas.r” } ).pretty()
{
"_id" : ObjectId("51c3bcddfbd5d7261b4cdb5b"),
"body" : "This is my first blog post",
"comments" : [
{
"name" : "Steve Noname",
"comment" : "Awesome Post"
}
],
"date" : ISODate("2013-06-20T00:00:00Z"),
"tags" : [
"adventure",
"mongodb"
],
"title" : "Hello World",
"username" : ”thomas.r"
}
Remove Comments / Articles
// remove comment with $pull
> var last_comment = {
"name" : "Steve Noname",
"comment" : "Awesome Post”
}
> db.articles.update(
{ _id: ObjectId("51c3bcddfbd5d7261b4cdb5b") },
{ $pull : { comments: last_comment } }
)
// remove article
> db.articles.remove(
{ _id: ObjectId("51c3bcddfbd5d7261b4cdb5b") }
)
MongoDB Drivers
Real applications are not
built in the shell
MongoDB has native
bindings for over 12
languages
MongoDB Drivers
•  Official Support for 12 languages
•  Community drivers for tons more
•  Drivers connect to mongo servers
•  Drivers translate BSON into native types
•  mongo shell is not a driver, but works like one in some

ways
•  Installed using typical means (npm, pecl, gem, pip)
Learn more about MongoDB
Manual: docs.mongodb.org
Online Training at MongoDB University
We've introduced a lot of
concepts here
Schema Design @ 11:00
Article

User
·Name
·Email address

·Name
·Slug
·Publish date
·Text
·Author

Comment[]
·Comment
·Date
·Author

Tag[]
·Value

Category[]
·Value
Replication @ 11:50
Client Application
Driver

Re
a

d

a
Re

d

Write

Secondary

Primary

Secondary
Sharding @ 14:00
www.etiennemansard.com
Indexing @ 15:50

7

1

2

5

6

16

9

12

18

21
#MongoDBDays

Questions ?
Thomas Rückstieß
thomas@mongodb.com
@tomonezero

Contenu connexe

Tendances

Back to Basics 1: Thinking in documents
Back to Basics 1: Thinking in documentsBack to Basics 1: Thinking in documents
Back to Basics 1: Thinking in documents
MongoDB
 
MongoDB and Ruby on Rails
MongoDB and Ruby on RailsMongoDB and Ruby on Rails
MongoDB and Ruby on Rails
rfischer20
 
Building Your First App: An Introduction to MongoDB
Building Your First App: An Introduction to MongoDBBuilding Your First App: An Introduction to MongoDB
Building Your First App: An Introduction to MongoDB
MongoDB
 
Building a Social Network with MongoDB
  Building a Social Network with MongoDB  Building a Social Network with MongoDB
Building a Social Network with MongoDB
Fred Chu
 

Tendances (20)

Webinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in DocumentsWebinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in Documents
 
Webinar: Schema Design
Webinar: Schema DesignWebinar: Schema Design
Webinar: Schema Design
 
Mongo DB schema design patterns
Mongo DB schema design patternsMongo DB schema design patterns
Mongo DB schema design patterns
 
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentos
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentosConceptos básicos. seminario web 3 : Diseño de esquema pensado para documentos
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentos
 
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
 
Back to Basics 1: Thinking in documents
Back to Basics 1: Thinking in documentsBack to Basics 1: Thinking in documents
Back to Basics 1: Thinking in documents
 
MongoDB Advanced Schema Design - Inboxes
MongoDB Advanced Schema Design - InboxesMongoDB Advanced Schema Design - Inboxes
MongoDB Advanced Schema Design - Inboxes
 
Dev Jumpstart: Schema Design Best Practices
Dev Jumpstart: Schema Design Best PracticesDev Jumpstart: Schema Design Best Practices
Dev Jumpstart: Schema Design Best Practices
 
Practical Ruby Projects With Mongo Db
Practical Ruby Projects With Mongo DbPractical Ruby Projects With Mongo Db
Practical Ruby Projects With Mongo Db
 
MongoDB and Schema Design
MongoDB and Schema DesignMongoDB and Schema Design
MongoDB and Schema Design
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 
MongoDB and Ruby on Rails
MongoDB and Ruby on RailsMongoDB and Ruby on Rails
MongoDB and Ruby on Rails
 
Socialite, the Open Source Status Feed Part 3: Scaling the Data Feed
Socialite, the Open Source Status Feed Part 3: Scaling the Data FeedSocialite, the Open Source Status Feed Part 3: Scaling the Data Feed
Socialite, the Open Source Status Feed Part 3: Scaling the Data Feed
 
Socialite, the Open Source Status Feed
Socialite, the Open Source Status FeedSocialite, the Open Source Status Feed
Socialite, the Open Source Status Feed
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
 
Building Your First App: An Introduction to MongoDB
Building Your First App: An Introduction to MongoDBBuilding Your First App: An Introduction to MongoDB
Building Your First App: An Introduction to MongoDB
 
Socialite, the Open Source Status Feed Part 2: Managing the Social Graph
Socialite, the Open Source Status Feed Part 2: Managing the Social GraphSocialite, the Open Source Status Feed Part 2: Managing the Social Graph
Socialite, the Open Source Status Feed Part 2: Managing the Social Graph
 
Webinar: Data Modeling Examples in the Real World
Webinar: Data Modeling Examples in the Real WorldWebinar: Data Modeling Examples in the Real World
Webinar: Data Modeling Examples in the Real World
 
Data Modeling for the Real World
Data Modeling for the Real WorldData Modeling for the Real World
Data Modeling for the Real World
 
Building a Social Network with MongoDB
  Building a Social Network with MongoDB  Building a Social Network with MongoDB
Building a Social Network with MongoDB
 

Similaire à Building your first app with mongo db

Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
Mongo db eveningschemadesign
Mongo db eveningschemadesignMongo db eveningschemadesign
Mongo db eveningschemadesign
MongoDB APAC
 
Building Your First Application with MongoDB
Building Your First Application with MongoDBBuilding Your First Application with MongoDB
Building Your First Application with MongoDB
MongoDB
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling
DATAVERSITY
 
S01 e01 schema-design
S01 e01 schema-designS01 e01 schema-design
S01 e01 schema-design
MongoDB
 
Webinar: Build an Application Series - Session 2 - Getting Started
Webinar: Build an Application Series - Session 2 - Getting StartedWebinar: Build an Application Series - Session 2 - Getting Started
Webinar: Build an Application Series - Session 2 - Getting Started
MongoDB
 

Similaire à Building your first app with mongo db (20)

MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
Mongo db eveningschemadesign
Mongo db eveningschemadesignMongo db eveningschemadesign
Mongo db eveningschemadesign
 
Webinar: Building Your First App
Webinar: Building Your First AppWebinar: Building Your First App
Webinar: Building Your First App
 
Building Your First Application with MongoDB
Building Your First Application with MongoDBBuilding Your First Application with MongoDB
Building Your First Application with MongoDB
 
Webinar: Building Your First MongoDB App
Webinar: Building Your First MongoDB AppWebinar: Building Your First MongoDB App
Webinar: Building Your First MongoDB App
 
Dev Jumpstart: Building Your First App
Dev Jumpstart: Building Your First AppDev Jumpstart: Building Your First App
Dev Jumpstart: Building Your First App
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev Teams
 
MongoDB & Mongoid with Rails
MongoDB & Mongoid with RailsMongoDB & Mongoid with Rails
MongoDB & Mongoid with Rails
 
The emerging world of mongo db csp
The emerging world of mongo db   cspThe emerging world of mongo db   csp
The emerging world of mongo db csp
 
MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup
 
S01 e01 schema-design
S01 e01 schema-designS01 e01 schema-design
S01 e01 schema-design
 
Schema Design with MongoDB
Schema Design with MongoDBSchema Design with MongoDB
Schema Design with MongoDB
 
Building Your First MongoDB App
Building Your First MongoDB AppBuilding Your First MongoDB App
Building Your First MongoDB App
 
Webinar: Build an Application Series - Session 2 - Getting Started
Webinar: Build an Application Series - Session 2 - Getting StartedWebinar: Build an Application Series - Session 2 - Getting Started
Webinar: Build an Application Series - Session 2 - Getting Started
 

Plus de MongoDB

Plus de MongoDB (20)

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Building your first app with mongo db

  • 1. #MongoDBDays Building your first app; an introduction to MongoDB Thomas Rückstieß Technical Services Engineer, MongoDB
  • 2. Notes to the Presenter •  Themes for this presentation: •  First presentation in the conference. Keep it fun •  User is likely brand new to MongoDB and comes from traditional relational background •  This is an introduction. Don't go deep.. Introduce concepts and refer to later presentations that build on these concepts.
  • 4. MongoDB is a ___________ database •  Document •  Open source •  High performance •  Horizontally scalable •  Full featured
  • 5. Document Database •  Not for .PDF & .DOC files •  A document is essentially an associative array with key/value pairs (possibly nested) { username : “thomas.r", num_logins : 39, last_login : ISODate("2013-10-08T16:46:21Z"), permissions : ["read", "write", "list", "admin"], company : { name : "MongoDB, Inc." location : "Sydney, Australia" } }
  • 6. Open Source •  MongoDB is an open source project •  On GitHub •  Licensed under the AGPL •  Started & sponsored by 10gen (now MongoDB, Inc.) •  Commercial licenses available •  Contributions welcome
  • 7. High Performance •  Written in C++ •  Extensive use of memory-mapped files i.e. read-through write-through memory caching. •  Runs nearly everywhere •  Data serialized as BSON (fast parsing) •  Full support for primary & secondary indexes •  Document model = less work
  • 8. Horizontally Scalable Shard 1 Shard 2 Shard 3 Horizontally Scalable Shard N
  • 9. Full Featured •  Ad Hoc queries •  Real time aggregation •  Rich query capabilities •  Strongly consistent •  Geospatial features •  Support for most programming languages •  Flexible schema
  • 10. Scalability & Performance Scalability & Performance Database Landscape Memcached MongoDB RDBMS Depth of Functionality
  • 12. Running MongoDB $ tar –z xvf mongodb-osx-x86_64-2.4.x.tgz $ cd mongodb-osx-i386-2.4.4/bin $ mkdir –p /data/db $ ./mongod
  • 13. Mongo Shell $ mongo MongoDB shell version: 2.4.4 connecting to: test > db.test.insert( { text: 'Welcome to MongoDB’ } ) > db.test.find().pretty() { "_id" : ObjectId("51c34130fbd5d7261b4cdb55"), "text" : "Welcome to MongoDB" }
  • 17. First step in any application is Determine your entities
  • 18. Entities in our Blogging System •  Users •  Articles •  Comments •  Tags •  Categories ( ? )
  • 19. In a relational database app We would start by doing schema design
  • 20. Typical (relational) ERD Category ·Name ·URL User ·Name ·Email address Article ·Name ·Slug ·Publish date ·Text Comment ·Comment ·Date ·Author Tag ·Name ·URL
  • 21. Relational schema design •  Large ERD Diagrams •  Complex “create table” statements •  ORMs to map tables to objects •  Tables just to join tables together •  Lots of revisions until we get it right
  • 22. In a MongoDB based app We start building our app and let the schema evolve
  • 23. MongoDB ERD Article User ·Name ·Email address ·Name ·Slug ·Publish date ·Text ·Author Comment[] ·Comment ·Date ·Author Tag[] ·Value Category[] ·Value
  • 26. Start with an object (or array, hash, dict, etc) > var user = { username: ’thomas.r', first_name: ’Thomas', last_name: ’Rückstieß', }
  • 27. Insert the Record > db test > use blog switched to db blog // syntax is “db.<collection>.<command>” > db.users.insert( user ) No db/collection creation necessary
  • 28. Retrieve the Record again // get one document (don’t care which one) > db.users.findOne() { "_id" : ObjectId("50804d0bd94ccab2da652599"), "username" : ”thomas.r", "first_name" : ”Thomas", "last_name" : ”Rückstieß" }
  • 29. _id •  _id is the primary key in MongoDB •  Any unique immutable value could be used •  Automatically created as an ObjectId if not provided •  Automatically indexed
  • 30. ObjectId •  ObjectId is a special 12 byte value •  Guaranteed to be unique across your cluster •  ObjectId("50804d0bd94ccab2da652599") ts mac pid inc
  • 31. Creating a Blog Article > db.articles.insert( { title: ‘Hello World’, body: ‘This is my first blog post’, date: new Date(‘2013-06-20’), username: ‘thomas.r’, tags: [‘adventure’, ‘mongodb’], comments: [ ] })
  • 32. Finding the Article > db.articles.find().pretty() { "_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"), "title" : "Hello World", "body" : "This is my first blog post", "date" : ISODate("2013-06-20T00:00:00Z"), "username" : ”thomas.r", "tags" : [ "adventure", "mongodb" ], "comments" : [ ] }
  • 33. Finding the Article > db.articles.find( { _id : ObjectId("51c3bafafbd5d7261b4cdb5a") } ) .pretty() { "_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"), "title" : "Hello World", "body" : "This is my first blog post", "date" : ISODate("2013-06-20T00:00:00Z"), "username" : ”thomas.r", "tags" : [ "adventure", "mongodb" ], "comments" : [ ] }
  • 34. Querying An Array > db.articles.find( { tags : 'adventure’ } ).pretty() { "_id" : ObjectId("51c3bcddfbd5d7261b4cdb5b"), "title" : "Hello World", "body" : "This is my first blog post", "date" : ISODate("2013-06-20T00:00:00Z"), "username" : ”thomas.r", "tags" : [ "adventure", "mongodb" ], "comments" : [ ] }
  • 35. Using Update to Add a Comment // the syntax is: “ update ( what, how ) “ > db.articles.update( { _id: ObjectId("51c3bcddfbd5d7261b4cdb5b”) }, { "$push" : { "comments" : { "name" : "Steve Noname", "comment" : "Awesome Post" } } )
  • 36. Article with Comment Embedded > db.articles.find( { username: “thomas.r” } ).pretty() { "_id" : ObjectId("51c3bcddfbd5d7261b4cdb5b"), "body" : "This is my first blog post", "comments" : [ { "name" : "Steve Noname", "comment" : "Awesome Post" } ], "date" : ISODate("2013-06-20T00:00:00Z"), "tags" : [ "adventure", "mongodb" ], "title" : "Hello World", "username" : ”thomas.r" }
  • 37. Remove Comments / Articles // remove comment with $pull > var last_comment = { "name" : "Steve Noname", "comment" : "Awesome Post” } > db.articles.update( { _id: ObjectId("51c3bcddfbd5d7261b4cdb5b") }, { $pull : { comments: last_comment } } ) // remove article > db.articles.remove( { _id: ObjectId("51c3bcddfbd5d7261b4cdb5b") } )
  • 39. Real applications are not built in the shell
  • 40. MongoDB has native bindings for over 12 languages
  • 41.
  • 42.
  • 43.
  • 44. MongoDB Drivers •  Official Support for 12 languages •  Community drivers for tons more •  Drivers connect to mongo servers •  Drivers translate BSON into native types •  mongo shell is not a driver, but works like one in some ways •  Installed using typical means (npm, pecl, gem, pip)
  • 45. Learn more about MongoDB
  • 47. Online Training at MongoDB University
  • 48. We've introduced a lot of concepts here
  • 49. Schema Design @ 11:00 Article User ·Name ·Email address ·Name ·Slug ·Publish date ·Text ·Author Comment[] ·Comment ·Date ·Author Tag[] ·Value Category[] ·Value
  • 50. Replication @ 11:50 Client Application Driver Re a d a Re d Write Secondary Primary Secondary