6. A grouping of MongoDB documents. A
collection is the equivalent of an RDBMS
table. A collection exists within a single
database. Collections do not enforce a
schema.
7. A record in MongoDB is a document, which is a data structure composed of field
and value pairs. MongoDB documents are similar to JSON objects. The values of
fields may include other documents, arrays, and arrays of documents.
The advantages of using documents are:
• Documents (i.e. objects) correspond to native data types in many programming languages.
• Embedded documents and arrays reduce need for expensive joins.
• Dynamic schema supports fluent polymorphism.
8. {
"_id" : ObjectId("54c955492b7c8eb21818bd09"),
"address" : {
"street" : "2 Avenue",
"zipcode" : "10075",
"building" : "1480",
"coord" : [ -73.9557413, 40.7720266 ]
},
"borough" : "Manhattan",
"cuisine" : "Italian",
"grades" : [
{
"date" : ISODate("2014-10-01T00:00:00Z"),
"grade" : "A",
"score" : 11
},
{
"date" : ISODate("2014-01-16T00:00:00Z"),
"grade" : "B",
"score" : 17
}
],
"name" : "Vella",
"restaurant_id" : "41704620"
}
BSON is a binary serialization format used
to store documents and make remote
procedure calls in MongoDB. The BSON
specification is located at bsonspec.org.
Double Boolean 64-bit integer
String Date Decimal128
Object Null Min key
Array Regular Expression Max key
Binary data JavaScript
ObjectId 32-bit integer
9. ObjectId
ObjectIds are small, likely unique, fast to generate, and ordered.
ObjectId values consists of 12-bytes, where the first four bytes are a timestamp that
reflect the ObjectId’s creation, specifically:
•a 4-byte value representing the seconds since the Unix epoch,
•a 3-byte machine identifier,
•a 2-byte process id, and
•a 3-byte counter, starting with a random value.
In MongoDB, each document stored in a collection requires a unique _id field that
acts as a primary key. If an inserted document omits the _id field, the MongoDB
driver automatically generates an ObjectId for the _id field.
31. WiredTiger is the default storage engine
starting in MongoDB 3.2. It is well-suited
for most workloads and is recommended
for new deployments
32. WiredTiger provides a document-level
concurrency model, checkpointing, and
compression, among other features
33. MMAPv1 is the original MongoDB
storage engine and is the default storage
engine for MongoDB versions before 3.2.
It performs well on workloads with high
volumes of reads and writes, as well as
in-place updates.
34. The In-Memory Storage Engine is
available in MongoDB Enterprise. Rather
than storing documents on-disk, it retains
them in-memory for more predictable
data latencies.