Welcome to our comprehensive guide on MongoDB! In this lesson, we'll explore the world of NoSQL databases, focusing on MongoDB, a popular, flexible, and scalable cross-platform document-oriented database. Let's dive in!
NoSQL (Not Only SQL) is a classification of database management systems that are designed to handle large, unstructured, and semi-structured data. Unlike traditional SQL databases that store data in tables with predefined structures, NoSQL databases use flexible schema designs.
MongoDB is a popular NoSQL database that stores data in JSON-like documents within a collection, offering high performance, high availability, and easy scalability. It's designed to handle a wide range of data types and structures, making it suitable for a variety of applications.
Follow these steps to install MongoDB on your system:
sudo service mongod start
mongo --version
The MongoDB shell is a JavaScript-based shell interface for MongoDB. To access the shell, open a terminal and type:
mongo
Let's create a database named myProject and a collection named users:
use myProject;
db.createCollection("users");Now, let's insert some data into the users collection:
db.users.insertMany([
{ name: "John Doe", age: 30, city: "New York" },
{ name: "Jane Smith", age: 28, city: "Los Angeles" }
]);To find all users in the users collection, use the following command:
db.users.find().pretty();In the next part of this tutorial, we'll delve deeper into MongoDB, exploring indexes, aggregation, and more. Stay tuned!
What is the basic unit of data in MongoDB?