Is this the name of cluster or database?

Hi, I’m new to MongoDB and I’m learning it by following the M001 course right now.

When we are on the “Database Deployments” page on the Atlas management platform, we can find an entry listed below, which is called “Sandbox”(the one I created by following the official tutorial of the M001 course). And when I am trying to connect to my MongoDB databases or cluster(whatever), the connection string prompts me to replace the “myFirstDatabase” with my own one so I used “Sandbox” instead. I supposed the “Sandbox” should be my database. However, when I connected to the database successfully, the tutorial showed me to use the command “show dbs” to list all the databases I have on my system. Then I got a list as follows:

sample_airbnb 55.70 MiB
sample_analytics 9.13 MiB
sample_geospatial 1.36 MiB
sample_guides 40.00 KiB
sample_mflix 47.80 MiB
sample_restaurants 6.59 MiB
sample_supplies 1.12 MiB
sample_training 54.66 MiB
sample_weatherdata 2.75 MiB
admin 340.00 KiB
local 3.13 GiB

I’m confused with those “Databases” listed above. Is “Sandbox” my database? Why there are many other databases stored in the Sandbox? A database contains other databases? So confusing here.

Hi @Rick_Qin and welcome in the MongoDB Community :muscle: !

In MongoDB Atlas, when you deploy a 3 nodes clusters (Free M0 or the more expensive M700), you are deploying a MongoDB Replica Set which contains databases which contains collections which finally contains documents.

“Database Deployments” in the UI refers to “Clusters” or “MongoDB Deployments” if you prefer.

Let’s see an example:

My Free forever M0 cluster is named “Free”.

I can connect to it using mongosh this command line that I get using the “Connect” button:

mongosh "mongodb+srv://" --apiVersion 1 --username max

As you can see in the connection string, the name of my cluster appears in the URI: “free”. The string at the end of the connection string - which defaults to “myFristDatabase” is the database that MongoDB will connect to once you are connected:

$ mongosh "mongodb+srv://" --apiVersion 1 --username max
Enter password: ***********
Current Mongosh Log ID:	62bdfb19cece31a364348a1e
Connecting to:		mongodb+srv://<credentials>
Using MongoDB:		5.0.9 (API Version 1)
Using Mongosh:		1.5.0

For mongosh info see:

Atlas Free-shard-0 [primary] myFirstDatabase> db

As you can see just above, the DB appears in the prompt as soon as I’m connected and I can confirm this by printing the content of the “db” command which returns “myFirstDatabase”.

Then when you type show dbs you list all the existing databases in your MongoDB cluster. As you loaded the sample data sets, you have all the sample databases + admin and local which are system collections.

If you create a new collection “coll” in this database by inserting a new doc in it, you’ll be able to see this database and collection:

Atlas Free-shard-0 [primary] myFirstDatabase> db.coll.insertOne({name:"Max"})
  acknowledged: true,
  insertedId: ObjectId("62bdfc0cf925691516399f62")
Atlas Free-shard-0 [primary] myFirstDatabase> show dbs
myFirstDatabase      16.00 KiB
sample_airbnb        52.77 MiB
sample_analytics      9.13 MiB
sample_geospatial     2.30 MiB
sample_guides        40.00 KiB
sample_mflix         46.52 MiB
sample_restaurants    6.61 MiB
sample_supplies       1.12 MiB
sample_training      53.61 MiB
sample_weatherdata    2.76 MiB
admin               332.00 KiB
local                 1.17 GiB
Atlas Free-shard-0 [primary] myFirstDatabase> show collections
Atlas Free-shard-0 [primary] myFirstDatabase> db.coll.findOne()
{ _id: ObjectId("62bdfc0cf925691516399f62"), name: 'Max' }

I hope this helps!
Keep up the good work in the MongoDB University!



Thank you so much for the information.
Now, I think I’ve got something. Let me recap it and see if I got it correct.

  1. In my case, the “sandbox” is the cluster name;

  2. I can specify a database name that is nonexistent in my system by far in the connection string. And in the connection string, clusterURI is the only thing that the mongosh command cares about. (Cause the database name can be any string valid)

  3. If the database specified in the connection string doesn’t exist, I can still connect to it. And the system will create it as long as I insert a collection into it.

Just a suggestion. As on the page “Database Deployment” there’s no chance to create any database directly but the cluster, why don’t we use “Cluster Deployment” as the page title instead? It will make the concept much clear and intuitive.


Sounds like you have everything correct! :muscle:
I already sent this feedback to the Atlas team a few weeks ago and this started a debate :smiley: ! You just provided me with more ammunition :gun: !