![]() |
SQL not allowed |

MongoDB is an open source document database with the scalability and flexibility that
you want with the querying and indexing that you need.
MongoDB supports dynamic schema design, allowing the documents in a collection
to have different fields and structures. The database uses a document storage
and data interchange format called BSON, which provides a binary representation of JSON-like documents.
- MongoDB stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time.
- The document model maps to the objects in your application code, making data easy to work with.
- Ad hoc queries, indexing, and real time aggregation provide powerful ways to access and analyze your data.
- MongoDB is a distributed database at its core, so high availability, horizontal scaling, and geographic distribution are built in and easy to use.
- MongoDB is free and open-source, published under the GNU Affero General Public License.
Install the MongoDB
Go to the https://www.mongodb.com/ website and download the mongodb.
MongoDB requires a data folder to store its files. The default location for the MongoDB data directory is c:\data\db. So you need to create this folder on that location.
or
If you have to install the MongoDB at a different location, then you need to specify an alternate path for \data\db by setting the path dbpath in mongod.
command: mongod --dbpath [PATH_TO_DATA_DIRECTORY]
Start MongoDB
⊿Go to the mongodb installed directory.
⊿Then open the mongod server.
mongod is a primary daemon process for the mongodb system. It handles data requests, manages data access, and performs background management operations.
⊿After open the mongo application.
Some commands
ᐅ display already exist databases
ᐅ switched to database(create a new or use already exist)
ᐅ display the current switched database
ᐅ add the following document(primary) to the database(Student)
primary: primary school students
each results stored separate document(primary) in mongodb.
add same record without error. Because mongodb generate unique ObjectId.
ᐅ display the all document values
ᐅ display the all document values in arrange format
ObjectId is added by mongodb. It's act as primary key(unique).
ᐅ display the particular name document
used regular expression to find the document
ᐅ update the particular document
ᐅ remove the particular document
ᐅ switched to database(create a new or use already exist)
ᐅ display the current switched database
ᐅ add the following document(primary) to the database(Student)
primary: primary school students
each results stored separate document(primary) in mongodb.
add same record without error. Because mongodb generate unique ObjectId.
ᐅ display the all document values
ᐅ display the all document values in arrange format
ObjectId is added by mongodb. It's act as primary key(unique).
ᐅ display the particular name document
used regular expression to find the document
- db.primary.find({"name":/a/}) //like %a%
- db.primary.find({"name":/^a/}) //like a%
- db.primary.find({"name":/a$/}) //like %a
ᐅ update the particular document
ᐅ remove the particular document