SlideShare a Scribd company logo
© 2010, OpenThink Labs. All Rights Reserved
MongoDB
Getting Started
Wildan Maulana
wildan.m@openthinklabs.com
© 2010, OpenThink Labs. All Rights Reserved
Overview
● A document is the basic unit of data for
MongoDB, roughly equivalent to a row in a
relational database management system (but
much more expressive).
● Similarly, a collection can be thought of as the
schema-free equivalent of a table.
● A single instance of MongoDB can host multiple
independent databases, each of which can have
its own collections and permissions.
● MongoDB comes with a simple but powerful
JavaScript shell, which is useful for the
administration of MongoDB instances and data
© 2010, OpenThink Labs. All Rights Reserved
Documents
● At the heart of MongoDB is the concept of a
document: an ordered set of keys with associated
values.
● Key/value pairs in documents are ordered—the earlier
document is distinct from the following document:
{"foo" : 3, "greeting" : "Hello, world!"}
● Values in documents are not just “blobs.” They can be
one of several different data types (or even an entire
embedded document—see “Embedded Documents”
on page ??). In this example the value for "greeting" is
a string, whereas the value for "foo" is an integer
© 2010, OpenThink Labs. All Rights Reserved
Documents - 2
● The keys in a document are strings. Any UTF-8
character is allowed in a key, with a few notable
exceptions:
● Keys must not contain the character 0 (the null
character). This character is used to signify the end of
a key.
● The . and $ characters have some special properties
and should be used only in certain circumstances, as
described in later chapters. In general, they should be
considered reserved, and drivers will complain if they
are used inappropriately.
● Keys starting with _ should be considered reserved;
although this is not strictly enforced.
© 2010, OpenThink Labs. All Rights Reserved
Documents - 2
● MongoDB is type-sensitive and case-sensitive.
For example, these documents are distinct:
● {"foo" : 3} and {"foo" : "3"}
● As are as these:
● {"foo" : 3} and {"Foo" : 3}
● A final important thing to note is that documents in
MongoDB cannot contain duplicate keys. For
example, the following is not a legal document:
● {"greeting" : "Hello, world!", "greeting" : "Hello,
MongoDB!"}
© 2010, OpenThink Labs. All Rights Reserved
Collections
A collection is a group of documents. If a document
is the MongoDB analog of a row
in a relational database, then a collection can be
thought of as the analog to a table.
© 2010, OpenThink Labs. All Rights Reserved
Collections
● Schema-Free
● Naming
● Subcollections
© 2010, OpenThink Labs. All Rights Reserved
Collections
Schema-Free
● Collections are schema-free. This means that the
documents within a single collection can have any
number of different “shapes.”
● For example, both of the following documents
could be stored in a single collection:
● {"greeting" : "Hello, world!"}
● {"foo" : 5}
© 2010, OpenThink Labs. All Rights Reserved
Collections
Schema-Free
● Why should we use more than one collection ?
● Keeping different kinds of documents in the same
collection can be a nightmare for developers and
admins. Developers need to make sure that each
query is only returning documents of a certain kind or
that the application code performing a query can
handle documents of different shapes. If we’re
querying for blog posts, it’s a hassle to weed out
documents containing author data.
© 2010, OpenThink Labs. All Rights Reserved
Collections
Schema-Free
● Why should we use more than one collection ?
● It is much faster to get a list of collections than to
extract a list of the types in a collection. For example,
if we had a type key in the collection that said whether
each document was a “skim,” “whole,” or “chunky
monkey” document, it would be much slower to find
those three values in a single collection than to have
three separate collections and query for their names
© 2010, OpenThink Labs. All Rights Reserved
Collections
Schema-Free
● Why should we use more than one collection ?
● Grouping documents of the same kind together in the
same collection allows for data locality. Getting several
blog posts from a collection containing only posts will
likely require fewer disk seeks than getting the same
posts from a collection containing posts and author
data.
© 2010, OpenThink Labs. All Rights Reserved
Collections
Schema-Free
● Why should we use more than one collection ?
● We begin to impose some structure on our documents
when we create indexes. (This is especially true in the
case of unique indexes.) These indexes are defined
per collection. By putting only documents of a single
type into the same collection, we can index our
collections more efficiently.
© 2010, OpenThink Labs. All Rights Reserved
Collections
Naming
● A collection is identified by its name. Collection
names can be any UTF-8 string, with a few
restrictions:
● The empty string ("") is not a valid collection name.
● Collection names may not contain the character 0
(the null character) because this delineates the end of
a collection name.
● You should not create any collections that start with
system., a prefix reserved for system collections. For
example, the system.users collection contains the
database’s users, and the system.namespaces
collection contains information about all of the
database’s collections.
●
© 2010, OpenThink Labs. All Rights Reserved
Collections
Naming - Subcollections
● One convention for organizing collections is to
use namespaced subcollections separated by
the . character.
● For example, an application containing a blog
might have a collection named blog.posts and a
separate collection named blog.authors. This is
for organizational purposes only—there is no
relationship between the blog collection (it doesn’t
even have to exist) and its “children.”
© 2010, OpenThink Labs. All Rights Reserved
Collections
Naming - Subcollections
● Although subcollections do not have any special
properties, they are useful and incorporated into
many MongoDB tools :
● GridFS, a protocol for storing large files, uses
subcollections to store file metadata separately from
content chunks
● The MongoDB web console organizes the data in its
DBTOP section by subcollection
● Most drivers provide some syntactic sugar for
accessing a subcollection of a given collection. For
example, in the database shell, db.blog will give you
the blog collection, and db.blog.posts will give you
the blog.posts collection.
© 2010, OpenThink Labs. All Rights Reserved
Subcollections are a great way to organize data in
MongoDB, and their use is highly
recommended.
© 2010, OpenThink Labs. All Rights Reserved
Databases
● In addition to grouping documents by collection,
MongoDB groups collections into databases.
● A single instance of MongoDB can host several
databases, each of which can be thought of as
completely independent
● A database has its own permissions, and each
database is stored in separate files on disk.
● A good rule of thumb is to store all data for a
single application in the same database.
© 2010, OpenThink Labs. All Rights Reserved
Database Naming Convention
● Database names can be any UTF-8 string, with
the following restrictions:
● The empty string ("") is not a valid database name.
● A database name cannot contain any of these
characters: ' ' (a single space), ., $, /, , or 0 (the null
character).
● Database names should be all lowercase.
● Database names are limited to a maximum of 64
bytes.
© 2010, OpenThink Labs. All Rights Reserved
Reserved Database Names
● There are also several reserved database names,
which you can access directly but have special
semantics. These are as follows:
● admin
This is the “root” database, in terms of authentication.
If a user is added to the admin database, the user
automatically inherits permissions for all databases.
There are also certain server-wide commands that can
be run only from the admin database, such as listing
all of the databases or shutting down the server.
● local
This database will never be replicated and can be
used to store any collections that should be local to a
single server
© 2010, OpenThink Labs. All Rights Reserved
Namespaces
● By prepending a collection’s name with its
containing database, you can get a fully qualified
collection name called a namespace.
● For instance, if you are using the blog.posts
collection in the cms database, the namespace
of that collection would be cms.blog.posts.
● Namespaces are limited to 121 bytes in length
and, in practice, should be less than 100 bytes
long.
© 2010, OpenThink Labs. All Rights Reserved
Getting and Starting MongoDB
● On Linux :
$ ./mongod
● On Windows :
$ mongod.exe
● When run with no arguments, mongod will use the
default data directory, /data/db/ (or C:datadb on
Windows), and port 27017. If the data directory
does not already exist or is not writable, the
server will fail to start. It is important to create the
data directory (e.g., mkdir -p /data/db/), and to
make sure your user has permission to write to
the directory, before starting MongoDB
© 2010, OpenThink Labs. All Rights Reserved
Getting and Starting MongoDB
● mongod also sets up a very basic HTTP server
that listens on a port 1,000 higher than the main
port, in this case 28017
● This means that you can get some administrative
information about your database by opening a
web browser and going to http://localhost:28017
© 2010, OpenThink Labs. All Rights Reserved
MongoDB Shell
● MongoDB comes with a JavaScript shell that
allows interaction with a MongoDB instance from
the command line
© 2010, OpenThink Labs. All Rights Reserved
Running the Shell
To start the shell, run the mongo executable:
$ ./mongo
© 2010, OpenThink Labs. All Rights Reserved
Running the Shell
● The shell is a full-featured JavaScript interpreter,
capable of running arbitrary JavaScript programs.
> x =
200
200
> x / 5;
40
> Math.sin(Math.PI / 2);
1
> new Date("2010/1/1");
"Fri Jan 01 2010 00:00:00 GMT-0500 (EST)"
> "Hello, World!".replace("World", "MongoDB");
Hello, MongoDB!
> function factorial (n) {
... if (n <= 1) return 1;
... return n * factorial(n - 1);
... }
> factorial(5);
120
© 2010, OpenThink Labs. All Rights Reserved
A MongoDB Client
● Although the ability to execute arbitrary JavaScript
is cool, the real power of the shell lies in the fact
that it is also a stand-alone MongoDB client. On
startup, the shell connects to the test database on
a MongoDB server and assigns this database
connection to the global variable db. This variable
is the primary access point to MongoDB through
the shell.
> use foobar
switched to db foobar
> db
foobar
© 2010, OpenThink Labs. All Rights Reserved
Basic Operations with the Shell
● Create
● Read
● Update
● Delete
© 2010, OpenThink Labs. All Rights Reserved
Create
> post = {"title" : "My Blog Post",
... "content" : "Here's my blog post.",
... "date" : new Date()}
{
"title" : "My Blog Post",
"content" : "Here's my blog post.",
"date" : "Sat Dec 12 2009 11:23:21 GMT-0500 (EST)"
}
> db.blog.insert(post)
> db.blog.find()
{
"_id" : ObjectId("4b23c3ca7525f35f94b60a2d"),
"title" : "My Blog Post",
"content" : "Here's my blog post.",
"date" : "Sat Dec 12 2009 11:23:21 GMT-0500 (EST)"
}
?
© 2010, OpenThink Labs. All Rights Reserved
Read
● find returns all of the documents in a collection. If
we just want to see one document from a
collection, we can use findOne:
> db.blog.findOne()
{
"_id" : ObjectId("4b23c3ca7525f35f94b60a2d"),
"title" : "My Blog Post",
"content" : "Here's my blog post.",
"date" : "Sat Dec 12 2009 11:23:21 GMT-0500 (EST)"
}
© 2010, OpenThink Labs. All Rights Reserved
Update
● If we would like to modify our post, we can use
update. update takes (at least) two parameters:
the first is the criteria to find which document to
update, and the second is the new document.
● Suppose we decide to enable comments on the
blog post we created earlier. We’ll need to add an
array of comments as the value for a new key in
our document.
© 2010, OpenThink Labs. All Rights Reserved
Update
> post.comments = []
[ ]
> db.blog.update({title : "My Blog Post"}, post)
> db.blog.find()
{
"_id" : ObjectId("4b23c3ca7525f35f94b60a2d"),
"title" : "My Blog Post",
"content" : "Here's my blog post.",
"date" : "Sat Dec 12 2009 11:23:21 GMT-0500 (EST)"
"comments" : [ ]
}
© 2010, OpenThink Labs. All Rights Reserved
Delete
● remove deletes documents permanently from the
database. Called with no parameters, it removes
all documents from a collection. It can also take a
document specifying criteria for removal. For
example, this would remove the post we just
created:
> db.blog.remove({title : "My Blog Post"})
© 2010, OpenThink Labs. All Rights Reserved
Tips for Using the Shell
● Because mongo is simply a JavaScript shell, you can get a great deal of help
for it by simply looking up JavaScript documentation online. The shell also
includes built-in help that can be accessed by typing help:
> help
db.help() help on db methods
db.mycoll.help() help on collection methods
rs.help() help on replica set methods
help connect connecting to a db help
help admin administrative help
help misc misc things to know
show dbs show database names
show collections show collections in current database
show users show users in current database
show profile show most recent system.profile entries with time >= 1ms
use <db_name> set current database
db.foo.find() list objects in collection foo
db.foo.find( { a : 1 } ) list objects in foo where a == 1
it result of the last line evaluated; use to further iterate
exit quit the mongo shell
© 2010, OpenThink Labs. All Rights Reserved
Print the JavaScript source code
> db.foo.update
function (query, obj, upsert, multi) {
assert(query, "need a query");
assert(obj, "need an object");
this._validateObject(obj);
this._mongo.update(this._fullName, query, obj,
upsert ? true : false, multi ? true : false);
}
Type the function without any parameters
© 2010, OpenThink Labs. All Rights Reserved
Inconvenient collection names
● Fetching a collection with db.collectionName
almost always works, unless the collection name
actually is a property of the database class.
> db.version
function () {
return this.serverBuildInfo().version;
}
> db.getCollection("version");
test.version
db.getCollection("foo-bar").
© 2010, OpenThink Labs. All Rights Reserved
Inconvenient collection names
● In JavaScript, x.y is identical to x['y']. This means
that subcollections can be accessed using
variables, not just literal names. That is, if you
needed to perform some operation on every blog
subcollection, you could iterate through them with
something like this:
● Instead of this
var collections = ["posts", "comments", "authors"];
for (i in collections) {
doStuff(db.blog[collections[i]]);
}
doStuff(db.blog.posts);
doStuff(db.blog.comments);
doStuff(db.blog.authors);
© 2010, OpenThink Labs. All Rights Reserved
Data Types
● Basic Data Types
● Numbers
● Dates
● Arrays
● Embedded Documents
● _id and ObjectIds
● ObjectIds
● Autogeneration of _id
© 2010, OpenThink Labs. All Rights Reserved
Data Types
Basic Data Types
● Documents in MongoDB can be thought
of as “JSON-like” in that they are
conceptually similar to objects in
JavaScript
● null
Null can be used to represent both a
null value and a nonexistent field:
{"x" : null}
● boolean
© 2010, OpenThink Labs. All Rights Reserved
Data Types
Basic Data Types
● 64-bit floating point number
All numbers in the shell will be of this type. Thus,
this will be a floating-point number:
{"x" : 3.14}
As will this:
{"x" : 3}
● string
Any string of UTF-8 characters can be
represented using the string type:
© 2010, OpenThink Labs. All Rights Reserved
Data Types
Basic Data Types
● symbol
This type is not supported by the shell. If the shell
gets a symbol from the database, it will convert it
into a string.
● object id
An object id is a unique 12-byte ID for documents.
{"x" : ObjectId()}
● date
Dates are stored as milliseconds since the epoch.
The time zone is not stored:
{"x" : new Date()}
© 2010, OpenThink Labs. All Rights Reserved
Data Types
Basic Data Types
● regular expression
Documents can contain regular expressions,
using JavaScript’s regular expression syntax:
{"x" : /foobar/i}
● code
Documents can also contain JavaScript code:
{"x" : function() { /* ... */ }}
● binary data
Binary data is a string of arbitrary bytes. It cannot
be manipulated from the shell.
© 2010, OpenThink Labs. All Rights Reserved
Data Types
Basic Data Types
● minimum value
BSON contains a special type representing the
smallest possible value. The shell does not have
a type for this.
● undefined
Undefined can be used in documents as well
(JavaScript has distinct types for null and
undefined):
{"x" : undefined}
© 2010, OpenThink Labs. All Rights Reserved
Data Types
Basic Data Types
● array
Sets or lists of values can be represented as
arrays:
{"x" : ["a", "b", "c"]}
● embedded document
Documents can contain entire documents,
embedded as values in a parent document:
{"x" : {"foo" : "bar"}}
© 2010, OpenThink Labs. All Rights Reserved
Data Types
Numbers
● JavaScript has one “number” type. Because
MongoDB has three number types (4-byte integer,
8-byte integer, and 8-byte float), the shell has to
hack around JavaScript’s limitations a bit.
© 2010, OpenThink Labs. All Rights Reserved
Data Types
Dates
● In JavaScript, the Date object is used for
MongoDB’s date type. When creating a new Date
object, always call new Date(...), not just
Date(...)
● For more information, see ECMAScript
specification section 15.9 (available for download
at http://www.ecmascript.org)
● Dates in the shell are displayed using local time
zone settings. However, dates in the database are
just stored as milliseconds since the epoch
© 2010, OpenThink Labs. All Rights Reserved
Data Types
Arrays
● Arrays are values that can be interchangeably
used for both ordered operations (as though they
were lists, stacks, or queues) and unordered
operations (as though they were sets).
● In the following document, the key "things" has an
array value:
{"things" : ["pie", 3.14]}
© 2010, OpenThink Labs. All Rights Reserved
Embedded Documents
● Embedded documents are entire MongoDB
documents that are used as the value for a key in
another document. They can be used to organize
data in a more natural way than just a flat
structure.
{
"name" : "John Doe",
"address" : {
"street" : "123 Park Street",
"city" : "Anytown",
"state" : "NY"
}
}
© 2010, OpenThink Labs. All Rights Reserved
_id and ObjectIds
● Every document stored in MongoDB must have
an "_id" key. The "_id" key’s value can be any
type, but it defaults to an ObjectId.
● In a single collection, every document must have
a unique value for "_id", which ensures that every
document in a collection can be uniquely
identified.
© 2010, OpenThink Labs. All Rights Reserved
ObjectIds
● ObjectId is the default type for "_id".
● ObjectId is easy to generate compared to
traditional auto incrementing primary key
● Because MongoDB was designed from the
beginning to be a distributed database, dealing
with many nodes is an important consideration
● ObjectIds use 12 bytes of storage, which gives
them a string representation that is 24
hexadecimal digits: 2 digits for each byte.
© 2010, OpenThink Labs. All Rights Reserved
ObjectIds
● The first four bytes of an ObjectId are a
timestamp in seconds since the epoch. This
provides a couple of useful properties:
● The timestamp, when combined with the next five
bytes, provides uniqueness at the granularity of a
second.
● Because the timestamp comes first, it means that
ObjectIds will sort in roughly insertion order. This is not
a strong guarantee but does have some nice
properties, such as making ObjectIds efficient to
index.
●
© 2010, OpenThink Labs. All Rights Reserved
ObjectIds
● The next three bytes of an ObjectId are a unique
identifier of the machine on which it was
generated. This is usually a hash of the machine’s
hostname. By including these bytes, we
guarantee that different machines will not
generate colliding ObjectIds.
© 2010, OpenThink Labs. All Rights Reserved
ObjectIds
● To provide uniqueness among different
processes generating ObjectIds concurrently on
a single machine, the next two bytes are taken
from the process identifier (PID) of the ObjectId-
generating process.
● The last three bytes are simply an incrementing
counter that is responsible for uniqueness within
a second in a single process. This allows for up
to 2563 (16,777,216) unique ObjectIds to be
generated per process in a single second.
© 2010, OpenThink Labs. All Rights Reserved
Autogeneration of _id
● As stated previously, if there is no "_id" key present when a document is
inserted, one will be automatically added to the inserted document.
● Although ObjectIds are designed to be lightweight and easy to generate,
there is still some overhead involved in their generation. The decision to
generate them on the client side reflects an overall philosophy of MongoDB:
work should be pushed out of the server and to the drivers whenever
possible. This philosophy reflects the fact that, even with scalable databases
like MongoDB, it is easier to scale out at the application layer than at the
database layer. Moving work to the client side reduces the burden requiring
the database to scale.
● By generating ObjectIds on the client side, drivers are capable of providing
richer APIs than would be otherwise possible. For example, a driver might
have its insert method either return the generated ObjectId or inject it
directly into the document that was inserted. If the driver allowed the server
to generate ObjectIds, then a separate query would be required to
determine the value of "_id" for an inserted document.
© 2010, OpenThink Labs. All Rights Reserved
Buy this book, on Amazon!
© 2010, OpenThink Labs. All Rights Reserved
Q&A
Thanks! ^_^

More Related Content

What's hot

What is in a Lucene index?
What is in a Lucene index?What is in a Lucene index?
What is in a Lucene index?
lucenerevolution
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
Hemant Sharma
 
How do i Meet MongoDB
How do i Meet MongoDBHow do i Meet MongoDB
How do i Meet MongoDB
Antonio Scalzo
 
Munching & crunching - Lucene index post-processing
Munching & crunching - Lucene index post-processingMunching & crunching - Lucene index post-processing
Munching & crunching - Lucene index post-processing
abial
 
Using Webservice in iOS
Using Webservice  in iOS Using Webservice  in iOS
Using Webservice in iOS
Mahboob Nur
 
Connecting to a REST API in iOS
Connecting to a REST API in iOSConnecting to a REST API in iOS
Connecting to a REST API in iOS
gillygize
 
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary fileCBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
ShivaniJayaprakash1
 
Apache Lucene: Searching the Web and Everything Else (Jazoon07)
Apache Lucene: Searching the Web and Everything Else (Jazoon07)Apache Lucene: Searching the Web and Everything Else (Jazoon07)
Apache Lucene: Searching the Web and Everything Else (Jazoon07)
dnaber
 
ToroDB: Scaling PostgreSQL like MongoDB by Álvaro Hernández at Big Data Spain...
ToroDB: Scaling PostgreSQL like MongoDB by Álvaro Hernández at Big Data Spain...ToroDB: Scaling PostgreSQL like MongoDB by Álvaro Hernández at Big Data Spain...
ToroDB: Scaling PostgreSQL like MongoDB by Álvaro Hernández at Big Data Spain...
Big Data Spain
 
Inverted index
Inverted indexInverted index
Inverted index
Krishna Gehlot
 
Dom parser
Dom parserDom parser
Dom parser
sana mateen
 
Lucene BootCamp
Lucene BootCampLucene BootCamp
Lucene BootCampGokulD
 
Mongo db nosql (1)
Mongo db nosql (1)Mongo db nosql (1)
Mongo db nosql (1)
Bhavesh Sarvaiya
 
Lucene indexing
Lucene indexingLucene indexing
Lucene indexing
Lucky Sharma
 
Lucene
LuceneLucene
Android APP-toggle case
Android APP-toggle caseAndroid APP-toggle case
Android APP-toggle case
Liang (Leon) Zhou
 
Mdb dn 2016_06_query_primer
Mdb dn 2016_06_query_primerMdb dn 2016_06_query_primer
Mdb dn 2016_06_query_primer
Daniel M. Farrell
 
Active Data Stores at 30,000ft
Active Data Stores at 30,000ftActive Data Stores at 30,000ft
Active Data Stores at 30,000ft
Jeffrey Sica
 

What's hot (20)

What is in a Lucene index?
What is in a Lucene index?What is in a Lucene index?
What is in a Lucene index?
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
How do i Meet MongoDB
How do i Meet MongoDBHow do i Meet MongoDB
How do i Meet MongoDB
 
Munching & crunching - Lucene index post-processing
Munching & crunching - Lucene index post-processingMunching & crunching - Lucene index post-processing
Munching & crunching - Lucene index post-processing
 
Using Webservice in iOS
Using Webservice  in iOS Using Webservice  in iOS
Using Webservice in iOS
 
Connecting to a REST API in iOS
Connecting to a REST API in iOSConnecting to a REST API in iOS
Connecting to a REST API in iOS
 
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary fileCBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
 
Apache Lucene: Searching the Web and Everything Else (Jazoon07)
Apache Lucene: Searching the Web and Everything Else (Jazoon07)Apache Lucene: Searching the Web and Everything Else (Jazoon07)
Apache Lucene: Searching the Web and Everything Else (Jazoon07)
 
ToroDB: Scaling PostgreSQL like MongoDB by Álvaro Hernández at Big Data Spain...
ToroDB: Scaling PostgreSQL like MongoDB by Álvaro Hernández at Big Data Spain...ToroDB: Scaling PostgreSQL like MongoDB by Álvaro Hernández at Big Data Spain...
ToroDB: Scaling PostgreSQL like MongoDB by Álvaro Hernández at Big Data Spain...
 
Inverted index
Inverted indexInverted index
Inverted index
 
Dom parser
Dom parserDom parser
Dom parser
 
Lucene BootCamp
Lucene BootCampLucene BootCamp
Lucene BootCamp
 
Mongo db nosql (1)
Mongo db nosql (1)Mongo db nosql (1)
Mongo db nosql (1)
 
Lucene indexing
Lucene indexingLucene indexing
Lucene indexing
 
Xml processors
Xml processorsXml processors
Xml processors
 
20081009 meeting
20081009 meeting20081009 meeting
20081009 meeting
 
Lucene
LuceneLucene
Lucene
 
Android APP-toggle case
Android APP-toggle caseAndroid APP-toggle case
Android APP-toggle case
 
Mdb dn 2016_06_query_primer
Mdb dn 2016_06_query_primerMdb dn 2016_06_query_primer
Mdb dn 2016_06_query_primer
 
Active Data Stores at 30,000ft
Active Data Stores at 30,000ftActive Data Stores at 30,000ft
Active Data Stores at 30,000ft
 

Viewers also liked

Node JS
Node JSNode JS
Node JS
Ynon Perek
 
Carolina Counts: An Update on the Bain Consulting Report
Carolina Counts: An Update on the Bain Consulting ReportCarolina Counts: An Update on the Bain Consulting Report
Carolina Counts: An Update on the Bain Consulting Report
ldconrad
 
Bain Resume Sample
Bain Resume SampleBain Resume Sample
Bain Resume Sample
ConsultingFact.com
 
Digital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBooster
Digital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBoosterDigital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBooster
Digital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBooster
Webanalisten .nl
 
Datomic
DatomicDatomic
Datomic
Jordan Leigh
 
Datomic
DatomicDatomic
Datomic
DatomicDatomic
Datomic
jperkelens
 
Waldorf Education
Waldorf EducationWaldorf Education
Waldorf Education
xMerodi
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
daisuke shimizu
 
Selena Gomez
Selena GomezSelena Gomez
Selena Gomez
guest5fa9931
 
Management Consulting
Management ConsultingManagement Consulting
Management Consulting
Alexandros Chatzopoulos
 
Sap fiori
Sap fioriSap fiori
Sap fiori
Anudeep Bhatia
 
French Property Market 2014
French Property Market 2014French Property Market 2014
French Property Market 2014
David Bourla
 
Clojure
ClojureClojure
Clojure
Rohit Vaidya
 
Medical devices
Medical devicesMedical devices
Medical devices
Somnath Zambare
 

Viewers also liked (20)

Node JS
Node JSNode JS
Node JS
 
Carolina Counts: An Update on the Bain Consulting Report
Carolina Counts: An Update on the Bain Consulting ReportCarolina Counts: An Update on the Bain Consulting Report
Carolina Counts: An Update on the Bain Consulting Report
 
Bain Resume Sample
Bain Resume SampleBain Resume Sample
Bain Resume Sample
 
Digital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBooster
Digital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBoosterDigital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBooster
Digital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBooster
 
Workshop
WorkshopWorkshop
Workshop
 
Datomic
DatomicDatomic
Datomic
 
Jim rohn
Jim  rohnJim  rohn
Jim rohn
 
Datomic
DatomicDatomic
Datomic
 
Datomic
DatomicDatomic
Datomic
 
Waldorf Education
Waldorf EducationWaldorf Education
Waldorf Education
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Tesco
TescoTesco
Tesco
 
Selena Gomez
Selena GomezSelena Gomez
Selena Gomez
 
Management Consulting
Management ConsultingManagement Consulting
Management Consulting
 
Sap fiori
Sap fioriSap fiori
Sap fiori
 
French Property Market 2014
French Property Market 2014French Property Market 2014
French Property Market 2014
 
intel core i7
intel core i7intel core i7
intel core i7
 
Oprah Winfrey
Oprah WinfreyOprah Winfrey
Oprah Winfrey
 
Clojure
ClojureClojure
Clojure
 
Medical devices
Medical devicesMedical devices
Medical devices
 

Similar to Getting Started - MongoDB

Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answers
jeetendra mandal
 
mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptx
RoopaR36
 
Caching in drupal
Caching in drupalCaching in drupal
Caching in drupal
Vivek Panicker
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
sethfloydjr
 
MongoDB : Introduction
MongoDB : IntroductionMongoDB : Introduction
MongoDB : IntroductionWildan Maulana
 
Mongo db dhruba
Mongo db dhrubaMongo db dhruba
Mongo db dhruba
Dhrubaji Mandal ♛
 
Mongo db
Mongo dbMongo db
Mongo db
Gyanendra Yadav
 
Mongodb
MongodbMongodb
Mongodb
Thiago Veiga
 
MongoDB
MongoDBMongoDB
No More SQL
No More SQLNo More SQL
No More SQL
Glenn Street
 
3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf
MarianJRuben
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
dinkar thakur
 
Building Spring Data with MongoDB
Building Spring Data with MongoDBBuilding Spring Data with MongoDB
Building Spring Data with MongoDBMongoDB
 
No SQL - MongoDB
No SQL - MongoDBNo SQL - MongoDB
No SQL - MongoDB
Mirza Asif
 
Asp.net interview questions
Asp.net interview questionsAsp.net interview questions
Asp.net interview questions
Akhil Mittal
 
Mongodb By Vipin
Mongodb By VipinMongodb By Vipin
Mongodb By Vipin
Vipin Mundayad
 
SURVEY ON MONGODB: AN OPEN-SOURCE DOCUMENT DATABASE
SURVEY ON MONGODB: AN OPEN-SOURCE DOCUMENT DATABASESURVEY ON MONGODB: AN OPEN-SOURCE DOCUMENT DATABASE
SURVEY ON MONGODB: AN OPEN-SOURCE DOCUMENT DATABASE
IAEME Publication
 

Similar to Getting Started - MongoDB (20)

Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answers
 
mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptx
 
Caching in drupal
Caching in drupalCaching in drupal
Caching in drupal
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
 
MongoDB : Introduction
MongoDB : IntroductionMongoDB : Introduction
MongoDB : Introduction
 
Mongo db dhruba
Mongo db dhrubaMongo db dhruba
Mongo db dhruba
 
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
 
Mongo db
Mongo dbMongo db
Mongo db
 
Mongodb hackathon 02
Mongodb hackathon 02Mongodb hackathon 02
Mongodb hackathon 02
 
Mongodb
MongodbMongodb
Mongodb
 
MongoDB
MongoDBMongoDB
MongoDB
 
Mongodb
MongodbMongodb
Mongodb
 
No More SQL
No More SQLNo More SQL
No More SQL
 
3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
 
Building Spring Data with MongoDB
Building Spring Data with MongoDBBuilding Spring Data with MongoDB
Building Spring Data with MongoDB
 
No SQL - MongoDB
No SQL - MongoDBNo SQL - MongoDB
No SQL - MongoDB
 
Asp.net interview questions
Asp.net interview questionsAsp.net interview questions
Asp.net interview questions
 
Mongodb By Vipin
Mongodb By VipinMongodb By Vipin
Mongodb By Vipin
 
SURVEY ON MONGODB: AN OPEN-SOURCE DOCUMENT DATABASE
SURVEY ON MONGODB: AN OPEN-SOURCE DOCUMENT DATABASESURVEY ON MONGODB: AN OPEN-SOURCE DOCUMENT DATABASE
SURVEY ON MONGODB: AN OPEN-SOURCE DOCUMENT DATABASE
 

More from Wildan Maulana

Hasil Pendataan Potensi Desa 2018
Hasil Pendataan Potensi Desa 2018Hasil Pendataan Potensi Desa 2018
Hasil Pendataan Potensi Desa 2018
Wildan Maulana
 
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Wildan Maulana
 
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam MelonKetahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Wildan Maulana
 
Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014Wildan Maulana
 
ICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi ArsipICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi ArsipWildan Maulana
 
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RWOpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RWWildan Maulana
 
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...Wildan Maulana
 
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyToolsPostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyToolsWildan Maulana
 
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...Wildan Maulana
 
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai SpMensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai SpWildan Maulana
 
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity ProviderKonfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity ProviderWildan Maulana
 
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)Wildan Maulana
 
Instalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphpInstalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphpWildan Maulana
 
River Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River RestorationRiver Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River RestorationWildan Maulana
 
Optimasi Limpasan Air Limbah Ke Kali Surabaya (Segmen Sepanjang – Jagir) De...
Optimasi Limpasan Air Limbah  Ke Kali Surabaya (Segmen Sepanjang – Jagir)  De...Optimasi Limpasan Air Limbah  Ke Kali Surabaya (Segmen Sepanjang – Jagir)  De...
Optimasi Limpasan Air Limbah Ke Kali Surabaya (Segmen Sepanjang – Jagir) De...
Wildan Maulana
 
Penilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan DasarPenilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan DasarWildan Maulana
 
Statistik Listrik
Statistik ListrikStatistik Listrik
Statistik Listrik
Wildan Maulana
 
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and UsesProyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and UsesWildan Maulana
 
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang TuaOpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang TuaWildan Maulana
 
Menggunakan AlisJK : Equating
Menggunakan AlisJK : EquatingMenggunakan AlisJK : Equating
Menggunakan AlisJK : Equating
Wildan Maulana
 

More from Wildan Maulana (20)

Hasil Pendataan Potensi Desa 2018
Hasil Pendataan Potensi Desa 2018Hasil Pendataan Potensi Desa 2018
Hasil Pendataan Potensi Desa 2018
 
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
 
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam MelonKetahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
 
Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014
 
ICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi ArsipICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi Arsip
 
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RWOpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
 
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
 
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyToolsPostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
 
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
 
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai SpMensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
 
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity ProviderKonfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
 
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
 
Instalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphpInstalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphp
 
River Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River RestorationRiver Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River Restoration
 
Optimasi Limpasan Air Limbah Ke Kali Surabaya (Segmen Sepanjang – Jagir) De...
Optimasi Limpasan Air Limbah  Ke Kali Surabaya (Segmen Sepanjang – Jagir)  De...Optimasi Limpasan Air Limbah  Ke Kali Surabaya (Segmen Sepanjang – Jagir)  De...
Optimasi Limpasan Air Limbah Ke Kali Surabaya (Segmen Sepanjang – Jagir) De...
 
Penilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan DasarPenilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan Dasar
 
Statistik Listrik
Statistik ListrikStatistik Listrik
Statistik Listrik
 
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and UsesProyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
 
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang TuaOpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
 
Menggunakan AlisJK : Equating
Menggunakan AlisJK : EquatingMenggunakan AlisJK : Equating
Menggunakan AlisJK : Equating
 

Recently uploaded

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 

Recently uploaded (20)

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 

Getting Started - MongoDB

  • 1. © 2010, OpenThink Labs. All Rights Reserved MongoDB Getting Started Wildan Maulana wildan.m@openthinklabs.com
  • 2. © 2010, OpenThink Labs. All Rights Reserved Overview ● A document is the basic unit of data for MongoDB, roughly equivalent to a row in a relational database management system (but much more expressive). ● Similarly, a collection can be thought of as the schema-free equivalent of a table. ● A single instance of MongoDB can host multiple independent databases, each of which can have its own collections and permissions. ● MongoDB comes with a simple but powerful JavaScript shell, which is useful for the administration of MongoDB instances and data
  • 3. © 2010, OpenThink Labs. All Rights Reserved Documents ● At the heart of MongoDB is the concept of a document: an ordered set of keys with associated values. ● Key/value pairs in documents are ordered—the earlier document is distinct from the following document: {"foo" : 3, "greeting" : "Hello, world!"} ● Values in documents are not just “blobs.” They can be one of several different data types (or even an entire embedded document—see “Embedded Documents” on page ??). In this example the value for "greeting" is a string, whereas the value for "foo" is an integer
  • 4. © 2010, OpenThink Labs. All Rights Reserved Documents - 2 ● The keys in a document are strings. Any UTF-8 character is allowed in a key, with a few notable exceptions: ● Keys must not contain the character 0 (the null character). This character is used to signify the end of a key. ● The . and $ characters have some special properties and should be used only in certain circumstances, as described in later chapters. In general, they should be considered reserved, and drivers will complain if they are used inappropriately. ● Keys starting with _ should be considered reserved; although this is not strictly enforced.
  • 5. © 2010, OpenThink Labs. All Rights Reserved Documents - 2 ● MongoDB is type-sensitive and case-sensitive. For example, these documents are distinct: ● {"foo" : 3} and {"foo" : "3"} ● As are as these: ● {"foo" : 3} and {"Foo" : 3} ● A final important thing to note is that documents in MongoDB cannot contain duplicate keys. For example, the following is not a legal document: ● {"greeting" : "Hello, world!", "greeting" : "Hello, MongoDB!"}
  • 6. © 2010, OpenThink Labs. All Rights Reserved Collections A collection is a group of documents. If a document is the MongoDB analog of a row in a relational database, then a collection can be thought of as the analog to a table.
  • 7. © 2010, OpenThink Labs. All Rights Reserved Collections ● Schema-Free ● Naming ● Subcollections
  • 8. © 2010, OpenThink Labs. All Rights Reserved Collections Schema-Free ● Collections are schema-free. This means that the documents within a single collection can have any number of different “shapes.” ● For example, both of the following documents could be stored in a single collection: ● {"greeting" : "Hello, world!"} ● {"foo" : 5}
  • 9. © 2010, OpenThink Labs. All Rights Reserved Collections Schema-Free ● Why should we use more than one collection ? ● Keeping different kinds of documents in the same collection can be a nightmare for developers and admins. Developers need to make sure that each query is only returning documents of a certain kind or that the application code performing a query can handle documents of different shapes. If we’re querying for blog posts, it’s a hassle to weed out documents containing author data.
  • 10. © 2010, OpenThink Labs. All Rights Reserved Collections Schema-Free ● Why should we use more than one collection ? ● It is much faster to get a list of collections than to extract a list of the types in a collection. For example, if we had a type key in the collection that said whether each document was a “skim,” “whole,” or “chunky monkey” document, it would be much slower to find those three values in a single collection than to have three separate collections and query for their names
  • 11. © 2010, OpenThink Labs. All Rights Reserved Collections Schema-Free ● Why should we use more than one collection ? ● Grouping documents of the same kind together in the same collection allows for data locality. Getting several blog posts from a collection containing only posts will likely require fewer disk seeks than getting the same posts from a collection containing posts and author data.
  • 12. © 2010, OpenThink Labs. All Rights Reserved Collections Schema-Free ● Why should we use more than one collection ? ● We begin to impose some structure on our documents when we create indexes. (This is especially true in the case of unique indexes.) These indexes are defined per collection. By putting only documents of a single type into the same collection, we can index our collections more efficiently.
  • 13. © 2010, OpenThink Labs. All Rights Reserved Collections Naming ● A collection is identified by its name. Collection names can be any UTF-8 string, with a few restrictions: ● The empty string ("") is not a valid collection name. ● Collection names may not contain the character 0 (the null character) because this delineates the end of a collection name. ● You should not create any collections that start with system., a prefix reserved for system collections. For example, the system.users collection contains the database’s users, and the system.namespaces collection contains information about all of the database’s collections. ●
  • 14. © 2010, OpenThink Labs. All Rights Reserved Collections Naming - Subcollections ● One convention for organizing collections is to use namespaced subcollections separated by the . character. ● For example, an application containing a blog might have a collection named blog.posts and a separate collection named blog.authors. This is for organizational purposes only—there is no relationship between the blog collection (it doesn’t even have to exist) and its “children.”
  • 15. © 2010, OpenThink Labs. All Rights Reserved Collections Naming - Subcollections ● Although subcollections do not have any special properties, they are useful and incorporated into many MongoDB tools : ● GridFS, a protocol for storing large files, uses subcollections to store file metadata separately from content chunks ● The MongoDB web console organizes the data in its DBTOP section by subcollection ● Most drivers provide some syntactic sugar for accessing a subcollection of a given collection. For example, in the database shell, db.blog will give you the blog collection, and db.blog.posts will give you the blog.posts collection.
  • 16. © 2010, OpenThink Labs. All Rights Reserved Subcollections are a great way to organize data in MongoDB, and their use is highly recommended.
  • 17. © 2010, OpenThink Labs. All Rights Reserved Databases ● In addition to grouping documents by collection, MongoDB groups collections into databases. ● A single instance of MongoDB can host several databases, each of which can be thought of as completely independent ● A database has its own permissions, and each database is stored in separate files on disk. ● A good rule of thumb is to store all data for a single application in the same database.
  • 18. © 2010, OpenThink Labs. All Rights Reserved Database Naming Convention ● Database names can be any UTF-8 string, with the following restrictions: ● The empty string ("") is not a valid database name. ● A database name cannot contain any of these characters: ' ' (a single space), ., $, /, , or 0 (the null character). ● Database names should be all lowercase. ● Database names are limited to a maximum of 64 bytes.
  • 19. © 2010, OpenThink Labs. All Rights Reserved Reserved Database Names ● There are also several reserved database names, which you can access directly but have special semantics. These are as follows: ● admin This is the “root” database, in terms of authentication. If a user is added to the admin database, the user automatically inherits permissions for all databases. There are also certain server-wide commands that can be run only from the admin database, such as listing all of the databases or shutting down the server. ● local This database will never be replicated and can be used to store any collections that should be local to a single server
  • 20. © 2010, OpenThink Labs. All Rights Reserved Namespaces ● By prepending a collection’s name with its containing database, you can get a fully qualified collection name called a namespace. ● For instance, if you are using the blog.posts collection in the cms database, the namespace of that collection would be cms.blog.posts. ● Namespaces are limited to 121 bytes in length and, in practice, should be less than 100 bytes long.
  • 21. © 2010, OpenThink Labs. All Rights Reserved Getting and Starting MongoDB ● On Linux : $ ./mongod ● On Windows : $ mongod.exe ● When run with no arguments, mongod will use the default data directory, /data/db/ (or C:datadb on Windows), and port 27017. If the data directory does not already exist or is not writable, the server will fail to start. It is important to create the data directory (e.g., mkdir -p /data/db/), and to make sure your user has permission to write to the directory, before starting MongoDB
  • 22. © 2010, OpenThink Labs. All Rights Reserved Getting and Starting MongoDB ● mongod also sets up a very basic HTTP server that listens on a port 1,000 higher than the main port, in this case 28017 ● This means that you can get some administrative information about your database by opening a web browser and going to http://localhost:28017
  • 23. © 2010, OpenThink Labs. All Rights Reserved MongoDB Shell ● MongoDB comes with a JavaScript shell that allows interaction with a MongoDB instance from the command line
  • 24. © 2010, OpenThink Labs. All Rights Reserved Running the Shell To start the shell, run the mongo executable: $ ./mongo
  • 25. © 2010, OpenThink Labs. All Rights Reserved Running the Shell ● The shell is a full-featured JavaScript interpreter, capable of running arbitrary JavaScript programs. > x = 200 200 > x / 5; 40 > Math.sin(Math.PI / 2); 1 > new Date("2010/1/1"); "Fri Jan 01 2010 00:00:00 GMT-0500 (EST)" > "Hello, World!".replace("World", "MongoDB"); Hello, MongoDB! > function factorial (n) { ... if (n <= 1) return 1; ... return n * factorial(n - 1); ... } > factorial(5); 120
  • 26. © 2010, OpenThink Labs. All Rights Reserved A MongoDB Client ● Although the ability to execute arbitrary JavaScript is cool, the real power of the shell lies in the fact that it is also a stand-alone MongoDB client. On startup, the shell connects to the test database on a MongoDB server and assigns this database connection to the global variable db. This variable is the primary access point to MongoDB through the shell. > use foobar switched to db foobar > db foobar
  • 27. © 2010, OpenThink Labs. All Rights Reserved Basic Operations with the Shell ● Create ● Read ● Update ● Delete
  • 28. © 2010, OpenThink Labs. All Rights Reserved Create > post = {"title" : "My Blog Post", ... "content" : "Here's my blog post.", ... "date" : new Date()} { "title" : "My Blog Post", "content" : "Here's my blog post.", "date" : "Sat Dec 12 2009 11:23:21 GMT-0500 (EST)" } > db.blog.insert(post) > db.blog.find() { "_id" : ObjectId("4b23c3ca7525f35f94b60a2d"), "title" : "My Blog Post", "content" : "Here's my blog post.", "date" : "Sat Dec 12 2009 11:23:21 GMT-0500 (EST)" } ?
  • 29. © 2010, OpenThink Labs. All Rights Reserved Read ● find returns all of the documents in a collection. If we just want to see one document from a collection, we can use findOne: > db.blog.findOne() { "_id" : ObjectId("4b23c3ca7525f35f94b60a2d"), "title" : "My Blog Post", "content" : "Here's my blog post.", "date" : "Sat Dec 12 2009 11:23:21 GMT-0500 (EST)" }
  • 30. © 2010, OpenThink Labs. All Rights Reserved Update ● If we would like to modify our post, we can use update. update takes (at least) two parameters: the first is the criteria to find which document to update, and the second is the new document. ● Suppose we decide to enable comments on the blog post we created earlier. We’ll need to add an array of comments as the value for a new key in our document.
  • 31. © 2010, OpenThink Labs. All Rights Reserved Update > post.comments = [] [ ] > db.blog.update({title : "My Blog Post"}, post) > db.blog.find() { "_id" : ObjectId("4b23c3ca7525f35f94b60a2d"), "title" : "My Blog Post", "content" : "Here's my blog post.", "date" : "Sat Dec 12 2009 11:23:21 GMT-0500 (EST)" "comments" : [ ] }
  • 32. © 2010, OpenThink Labs. All Rights Reserved Delete ● remove deletes documents permanently from the database. Called with no parameters, it removes all documents from a collection. It can also take a document specifying criteria for removal. For example, this would remove the post we just created: > db.blog.remove({title : "My Blog Post"})
  • 33. © 2010, OpenThink Labs. All Rights Reserved Tips for Using the Shell ● Because mongo is simply a JavaScript shell, you can get a great deal of help for it by simply looking up JavaScript documentation online. The shell also includes built-in help that can be accessed by typing help: > help db.help() help on db methods db.mycoll.help() help on collection methods rs.help() help on replica set methods help connect connecting to a db help help admin administrative help help misc misc things to know show dbs show database names show collections show collections in current database show users show users in current database show profile show most recent system.profile entries with time >= 1ms use <db_name> set current database db.foo.find() list objects in collection foo db.foo.find( { a : 1 } ) list objects in foo where a == 1 it result of the last line evaluated; use to further iterate exit quit the mongo shell
  • 34. © 2010, OpenThink Labs. All Rights Reserved Print the JavaScript source code > db.foo.update function (query, obj, upsert, multi) { assert(query, "need a query"); assert(obj, "need an object"); this._validateObject(obj); this._mongo.update(this._fullName, query, obj, upsert ? true : false, multi ? true : false); } Type the function without any parameters
  • 35. © 2010, OpenThink Labs. All Rights Reserved Inconvenient collection names ● Fetching a collection with db.collectionName almost always works, unless the collection name actually is a property of the database class. > db.version function () { return this.serverBuildInfo().version; } > db.getCollection("version"); test.version db.getCollection("foo-bar").
  • 36. © 2010, OpenThink Labs. All Rights Reserved Inconvenient collection names ● In JavaScript, x.y is identical to x['y']. This means that subcollections can be accessed using variables, not just literal names. That is, if you needed to perform some operation on every blog subcollection, you could iterate through them with something like this: ● Instead of this var collections = ["posts", "comments", "authors"]; for (i in collections) { doStuff(db.blog[collections[i]]); } doStuff(db.blog.posts); doStuff(db.blog.comments); doStuff(db.blog.authors);
  • 37. © 2010, OpenThink Labs. All Rights Reserved Data Types ● Basic Data Types ● Numbers ● Dates ● Arrays ● Embedded Documents ● _id and ObjectIds ● ObjectIds ● Autogeneration of _id
  • 38. © 2010, OpenThink Labs. All Rights Reserved Data Types Basic Data Types ● Documents in MongoDB can be thought of as “JSON-like” in that they are conceptually similar to objects in JavaScript ● null Null can be used to represent both a null value and a nonexistent field: {"x" : null} ● boolean
  • 39. © 2010, OpenThink Labs. All Rights Reserved Data Types Basic Data Types ● 64-bit floating point number All numbers in the shell will be of this type. Thus, this will be a floating-point number: {"x" : 3.14} As will this: {"x" : 3} ● string Any string of UTF-8 characters can be represented using the string type:
  • 40. © 2010, OpenThink Labs. All Rights Reserved Data Types Basic Data Types ● symbol This type is not supported by the shell. If the shell gets a symbol from the database, it will convert it into a string. ● object id An object id is a unique 12-byte ID for documents. {"x" : ObjectId()} ● date Dates are stored as milliseconds since the epoch. The time zone is not stored: {"x" : new Date()}
  • 41. © 2010, OpenThink Labs. All Rights Reserved Data Types Basic Data Types ● regular expression Documents can contain regular expressions, using JavaScript’s regular expression syntax: {"x" : /foobar/i} ● code Documents can also contain JavaScript code: {"x" : function() { /* ... */ }} ● binary data Binary data is a string of arbitrary bytes. It cannot be manipulated from the shell.
  • 42. © 2010, OpenThink Labs. All Rights Reserved Data Types Basic Data Types ● minimum value BSON contains a special type representing the smallest possible value. The shell does not have a type for this. ● undefined Undefined can be used in documents as well (JavaScript has distinct types for null and undefined): {"x" : undefined}
  • 43. © 2010, OpenThink Labs. All Rights Reserved Data Types Basic Data Types ● array Sets or lists of values can be represented as arrays: {"x" : ["a", "b", "c"]} ● embedded document Documents can contain entire documents, embedded as values in a parent document: {"x" : {"foo" : "bar"}}
  • 44. © 2010, OpenThink Labs. All Rights Reserved Data Types Numbers ● JavaScript has one “number” type. Because MongoDB has three number types (4-byte integer, 8-byte integer, and 8-byte float), the shell has to hack around JavaScript’s limitations a bit.
  • 45. © 2010, OpenThink Labs. All Rights Reserved Data Types Dates ● In JavaScript, the Date object is used for MongoDB’s date type. When creating a new Date object, always call new Date(...), not just Date(...) ● For more information, see ECMAScript specification section 15.9 (available for download at http://www.ecmascript.org) ● Dates in the shell are displayed using local time zone settings. However, dates in the database are just stored as milliseconds since the epoch
  • 46. © 2010, OpenThink Labs. All Rights Reserved Data Types Arrays ● Arrays are values that can be interchangeably used for both ordered operations (as though they were lists, stacks, or queues) and unordered operations (as though they were sets). ● In the following document, the key "things" has an array value: {"things" : ["pie", 3.14]}
  • 47. © 2010, OpenThink Labs. All Rights Reserved Embedded Documents ● Embedded documents are entire MongoDB documents that are used as the value for a key in another document. They can be used to organize data in a more natural way than just a flat structure. { "name" : "John Doe", "address" : { "street" : "123 Park Street", "city" : "Anytown", "state" : "NY" } }
  • 48. © 2010, OpenThink Labs. All Rights Reserved _id and ObjectIds ● Every document stored in MongoDB must have an "_id" key. The "_id" key’s value can be any type, but it defaults to an ObjectId. ● In a single collection, every document must have a unique value for "_id", which ensures that every document in a collection can be uniquely identified.
  • 49. © 2010, OpenThink Labs. All Rights Reserved ObjectIds ● ObjectId is the default type for "_id". ● ObjectId is easy to generate compared to traditional auto incrementing primary key ● Because MongoDB was designed from the beginning to be a distributed database, dealing with many nodes is an important consideration ● ObjectIds use 12 bytes of storage, which gives them a string representation that is 24 hexadecimal digits: 2 digits for each byte.
  • 50. © 2010, OpenThink Labs. All Rights Reserved ObjectIds ● The first four bytes of an ObjectId are a timestamp in seconds since the epoch. This provides a couple of useful properties: ● The timestamp, when combined with the next five bytes, provides uniqueness at the granularity of a second. ● Because the timestamp comes first, it means that ObjectIds will sort in roughly insertion order. This is not a strong guarantee but does have some nice properties, such as making ObjectIds efficient to index. ●
  • 51. © 2010, OpenThink Labs. All Rights Reserved ObjectIds ● The next three bytes of an ObjectId are a unique identifier of the machine on which it was generated. This is usually a hash of the machine’s hostname. By including these bytes, we guarantee that different machines will not generate colliding ObjectIds.
  • 52. © 2010, OpenThink Labs. All Rights Reserved ObjectIds ● To provide uniqueness among different processes generating ObjectIds concurrently on a single machine, the next two bytes are taken from the process identifier (PID) of the ObjectId- generating process. ● The last three bytes are simply an incrementing counter that is responsible for uniqueness within a second in a single process. This allows for up to 2563 (16,777,216) unique ObjectIds to be generated per process in a single second.
  • 53. © 2010, OpenThink Labs. All Rights Reserved Autogeneration of _id ● As stated previously, if there is no "_id" key present when a document is inserted, one will be automatically added to the inserted document. ● Although ObjectIds are designed to be lightweight and easy to generate, there is still some overhead involved in their generation. The decision to generate them on the client side reflects an overall philosophy of MongoDB: work should be pushed out of the server and to the drivers whenever possible. This philosophy reflects the fact that, even with scalable databases like MongoDB, it is easier to scale out at the application layer than at the database layer. Moving work to the client side reduces the burden requiring the database to scale. ● By generating ObjectIds on the client side, drivers are capable of providing richer APIs than would be otherwise possible. For example, a driver might have its insert method either return the generated ObjectId or inject it directly into the document that was inserted. If the driver allowed the server to generate ObjectIds, then a separate query would be required to determine the value of "_id" for an inserted document.
  • 54. © 2010, OpenThink Labs. All Rights Reserved Buy this book, on Amazon!
  • 55. © 2010, OpenThink Labs. All Rights Reserved Q&A Thanks! ^_^