Professional Documents
Culture Documents
The following table outlines some of the common notions in MySQL and MongoDB.
MySQL MongoDB
Database Database
Table Collection
Row Document
Column Field
Joins Embedded documents
& Linking
Foreign Key Reference
Like MySQL, MongoDB also provides rich set of features and functionality far beyond those
provided in simple key-value stores.
Features of MongoDB
In this section, we’ll see the features of MongoDB that allows us to operate efficiently.
Document-Oriented Storage
Full Index Support
Replication and high availability
Auto-Sharding
Fast In-Place Updates
Map/Reduce
GridFS
Professional Support by MongoDB
Documents
The smallest unit which plays a vital role in MongoDB is the document. It is simply
analogous to a row in a relational database but there is one big difference ie. not every
document requires to have the interchangeable schema – each of them can have distinct fields
and that is a very functional feature in current situation. MongoDB doesn't enforce a schema
like RDBMS. In short, a document is a multi dimensional array. In the context of MongoDB,
document is a JSON array. MongoDB documents are composed of field and value pairs and
have the following structure:
{
Field1: Value1,
Field2: Value2,
.....
FieldN:ValueN
The value of a field can be any of the BSON data types which will be discussed later in the
chapter.
For example,
Collections
In the following example, it is shown that two MongoDB documents, which belongs to same
collection, storing data of different structures.
{Name:Vimala} {Age:28}
3. Don’t use “$” character within the name of a collection. $ is reserved character in
MongoDB.
options document Optional. Configuration options for memory size and indexing
The above syntax inserts the documents into the collection. If the collection does not exist,
the insert() method creates the collection.
For example,
db.student.insert({Name:Vimala})
The insert() method creates the collection ‘student’ automatically with one document. You
can check the created collection by using the command ‘show collections’
>show collections
student
system.indexes