The term "NoSQL" actually encompasses a wide variety of different database technologies that were developed in response to the demands dictated by modern applications and Internet of Things (IoT) devices. The massive volumes of new, rapidly changing data types created by the linking of numerous systems and devices have presented challenges for traditional DBMSes:
- Relational databases were never designed to cope with the scale and agility challenges demanded by modern applications
- Nor were they built to take advantage of the cheap storage and processing power available to today's servers.
One of the most popular NoSQL databases is MongoDB. In fact, it's the leading non-relational database in the world. As such, it's the perfect starting place for learning NoSQL operations like indexing, regular expression, data sharding, etc. In the next few blogs, we'll learn how to work with MongoDB using the new Navicat for MongoDB database management & design tool. In today's tutorial, we start with the basics of database and document creation.
Creating a new Database
In this section we'll connect to our active MongoDB service and add a brand new database.
- Launch the Navicat for MongoDB application.
- Click the Connection... button on the main toolbar and select MongoDB... from the list:
- On the New Connection dialog, enter a name in the Connection Name field:
You can test the connection by clicking the Test Connection button.
If you need it, you can also obtain the server URI - i.e. mongodb://localhost:27017/ - by clicking the URI button.
- Click the OK button to close the dialog and create the connection. It will then appear in the left-hand Connection list.
With our connection in place, we are now ready to create a new database.
- Double-click the connection in the Connection list to open the database connection.
- Next, right-click the connection name and choose Create Database... from the context list.
- A dialog will appear in which you can provide the database name. After you have done so, click the OK button to close the dialog and create the new database.
Behind the scenes, Navicat employs the MongoDB "use" command to create the database. It will then appear under the current connection in the left-hand Connection list.
Now, we'll add a collection. A Collection is a group of MongoDB documents. It is the equivalent of an DBMS table. A collection exists within a single database. Typically, all documents in a collection are related in purpose or otherwise similar in some way or another.
- If you expand the Database object by clicking on the arrow to the left of the DB name, you will see all of the database objects, including its Collections:
Moreover, clicking on the Database object or any of its objects will enable applicable commands on the Database Objects Toolbar, in particular, the New Collection, Import Wizard, and Export Wizard buttons:
- Click the New Collection button. That will bring up a new Untitled Collection Tab:
It contains several child tabs for specifying all of the collection's attributes. We will cover these in a future blog. For now, we'll save it with the defaults.
- Click the Save button on the Untitled Collection Tab and enter the Collection name in the prompt.
The new collection will be added to the Database Explorer, under the Collections object:
Conclusion
In today's tutorial, we learned the basics of database and document creation in MongoDB using the new Navicat for database management & design tool. So far, the process has been similar than that of traditional DBMSes. In the next blog, we'll be getting into uncharted territory when we add documents to our collection.