Mongo DB
Mongo DB
Mongo DB
Database
Database is a physical container for collections. Each database gets its own
set of files on the file system. A single MongoDB server typically has multiple
databases.
Collection
Collection is a group of MongoDB documents. It is the equivalent of an RDBMS
table. A collection exists within a single database. Collections do not enforce
a schema. Documents within a collection can have different fields. Typically,
all documents in a collection are of similar or related purpose.
Document
1. _id – This is a field required in every MongoDB document. The _id field
represents a unique value in the MongoDB document. The _id field is like
the document's primary key. If you create a new document without an _id
field, MongoDB will automatically create the field.
The following diagram shows an example of Fields with Key value pairs. So
in the example below CustomerID and 11 is one of the key value pair's
defined in the document.
Just a quick note on the key difference between the _id field and a normal
collection field. The _id field is used to uniquely identify the documents in a
collection and is automatically added by MongoDB when the collection is created.
Database Database
Table Collection
Tuple/Row Document
Column Field
Mysqld/Oracle Mongod
mysql/sqlplus Mongo
Sample Document
Following example shows the document structure of a blog site, which is
simply a comma separated key value pair.
_id: ObjectId(7df78ad8902c)
url: 'http://www.tutorialspoint.com',
likes: 100,
comments: [
user:'user1',
like: 0
},
user:'user2',
like: 5
MongoDB - Advantages
Any relational database has a typical schema design that shows number of
tables and the relationship between these tables. While in MongoDB, there is
no concept of relationship.
No complex joins.
Tuning.
Uses internal memory for storing the (windowed) working set, enabling faster
access of data.
Data Hub
Key Features
High Performance
Support for embedded data models reduces I/O activity on database system.
Indexes support faster queries and can include keys from embedded documents and
arrays.
MongoDB supports a rich query language to support read and write operations
(CRUD) as well as:
Data Aggregation
Text Search and Geospatial Queries.
High Availability
Horizontal Scalability
In addition, MongoDB provides pluggable storage engine API that allows third parties to
develop storage engines for MongoDB.