Beruflich Dokumente
Kultur Dokumente
What is MongoDB?
MongoDB is NOSQL Database written in C++ language .It is open Source and it is Document
Oriented database that provides high performance, easy scalability and high availability.
MongoDB concept of Collections and Documents.
Dynamic Schemas: - In Relational Database if we want save student data, we want create tables
and columns to it, this is called Defined schema. This will be easy when we have less data in our
tables, but what if we have millions of data. Migration to the updated schema would be a hectic
job. NOSQL Database this is Solved, there is not required defined schema in NOSQL Database.
Sharding: - In Sharding, large database into small partitioned, faster and easily manageable
database.
In Relational Database follows vertical architecture, where single serve holds the all data. In
Relational database sharding is not default, to achieve this we can put lot of effort. Because
integrity (Inserting/Updating), multiple tables joining etc.
In NOSQL Database Sharding is by default. No additional effort. It is automatically spread data
across the server. Fetch the data from server in faster
Replication: - Auto data Replication is also supported in NOSQL Database by default. Hence, one
DB server goes down, data is restore and its copy create another one in network.
Integrated caching: - Many NOSQL Database supports Integrated Caching. Where in demand
data stored in cache to make quire faster.
Database: - Database in MongoDB is nothing but Container for Collections. Collection is nothing
but Tables in RDBMS.
Document: - Document in MongoDB is nothing but the set of key-value pairs. These documents
will have dynamic schema which means that the documents in the same collection do not need to
possess the same set of fields.
RDBMS MONGODB
Database Database
Tables Collections
Rows Documents
Column Field
Joins Embedded Documents
How to Run MongoDB in our System
Go to C: drive
Then
Go to Program Files
Then
Go to MongoDB Folder
Then
Hold the Shift Key and Right click the Mouse in that select the Open Command Window Here
Then
Type mongod.exe and click Enter
It will be show the error because there is C:data\db Folder is not presented Then we want
create Data folder in C: drive and then Data folder create db folder
Then again go to MongoDB folder in C: drive and then Hold the Shift Key and Right click the
Mouse in that select the Open Command Window Here
Then
Type mongo.exe
The connection is accepted
How to create Database in MongoDB
In MongoDB to Creating Database using use Command, if that database name is exist it is
switched to that DB Otherwise it created.
Database names can be almost any character in the ASCII range. But they can't contain an empty
string, a dot (i.e. ".") or " ".
You can't use "$" character within the name of a collection. "$" is reserved.
A Collection name must not exceed 128 characters. It will be nice if you keep it within 80/90
characters.
Syntax: - db.createCollection(collection_name,<options>)
Other way
Syntax: db.collectionname.insert ({Document1})
Ex: - db.subjects.insert({subjectname: maths})
And then press F5 button, this is if the collection name is present then it will be insert this
documents otherwise collection will create and insert will done
How to drop a Database?
Syntax: db.dropDatabase() then press F5 the switched database will be dropped.
Equal:
Syntax: db.collection name.find({field name :{$eq:value}})
Not Equal:
Syntax: db. collection Name.find({fieldname:{$ne:Value}