podcastfan88
podcastfan88

Reputation: 1070

What is a Mongo database vs. a cluster?

This is the newbiest question ever but I don't understand these instructions from MongoDB:

Replace DATABASE with the name of the database you wish to import/export to your cluster, and COLLECTION with the name of the collection you wish to import/export to your cluster.

I understand what "collections" are because I see them in the admin panel under "collections."

But I don't see "databases" listed anywhere, nor do I see clusters.

If my account dashboard shows this:

MyProject > Cluster0 > MyCollection

What do I write here?

mongo "mongodb+srv://CLUSTER.kaarp.mongodb.net/DATABASE"

Upvotes: 9

Views: 6085

Answers (3)

Indra
Indra

Reputation: 521

Yes, it is very confusing and wastes a lot of time for lots of people to figure out things this way. When there is a hierarchy of things like project>cluster>database>collection, this should be very obvious in the UI and in the documentation as well.

To summarize, when you go to MongoDB Atlas you will see a link to projects in your account. Select this option to display the list of projects. Select a project and that will take you to the project page which displays the list of clusters in the project. A cluster is a group of machines which works together to store your databases and at the same time provides fault tolerance, high availability and scalability.

Every database resides in a cluster and every collection resides in a database. Hence the hierarchy project>cluster>database>collection. As a developer, you instinct will be to create a database in a cluster and then use it to store your collections in the database. But there is no button to create a database!

It seems you can not create a database directly but only as part of creating a collection. So you have to create a collection by navigating the "Browse Collection" link. At the time of creating the collection, you will be able to set the name of the new database to host your collection.

However, once you have created at least one database as above, you will be able to see the "Create Database" button! Pretty weird workflow to me.

Upvotes: 4

Yariv
Yariv

Reputation: 1710

  • In MongoDB Atlas the term "Cluster" is an alias to the term 'A Group of Database'.
  • When you create a cluster give it a name that summarizes all the databases you plan to host there.
  • So where can you create databases inside the cluster ? See the attached image, here are the details:
    1. For that you need to navigate to the collections window , click the "Browse Collections" button.
    2. Then in the new window that opens you will see a "Create Database" button.
    3. FYI: M0 free clusters and M2/M5 shared clusters can have a maximum of 100 databases and 500 collections total. Link... enter image description here

enter image description here

Upvotes: 8

aixecador
aixecador

Reputation: 876

It is confusing for me too. I am using MongoDB Atlas and I discovered that, when you create a collection for the first time, you are asked to create a database name. As far as I understand, the hierarchy goes cluster > database > collection.

Upvotes: 1

Related Questions