Share
Explore

MongoDB Atlas organizational structure follows a hierarchical model

image.png

A MongoDB connection string connects you to a cluster, and within that cluster you can create and manage multiple databases. Here's a detailed explanation:

Connection String Behavior

The connection string format:
javascript
mongodb+srv://<username>:<password>@<cluster-address>/<dbname>?retryWrites=true&w=majority

connects you to the cluster level, and:
The <dbname> portion is optional and defaults to "test" if not specified
You can create multiple databases in the same cluster using this single connection
Each database can be created implicitly when you first store data in it

Example Usage

javascript
// Connect to cluster and work with multiple databases
const mongoose = require('mongoose');
const uri = "mongodb+srv://username:password@cluster0.example.mongodb.net/";

// Create/access different databases in the same cluster
const devDB = mongoose.createConnection(`${uri}development`);
const prodDB = mongoose.createConnection(`${uri}production`);

This approach allows you to maintain multiple databases within a single cluster while using the same connection infrastructure, making it an efficient way to organize different data sets or environments
.

MongoDB's organizational structure follows a hierarchical model:

Account Hierarchy

MongoDB Atlas Account (Organization)
One Atlas account/organization can contain multiple projects
Each project can contain multiple clusters
Each cluster can host multiple databases
Looking at the image, we can see the Atlas dashboard interface that demonstrates this hierarchy:
The left sidebar shows the organization-level navigation
The main screen shows "Projects" where you can manage multiple clusters
Each project (like "Project 0" shown) can contain clusters (shown as "1 Cluster" in the image)

Practical Implementation

This hierarchical structure allows for:
Logical separation of different applications or environments
Independent scaling of resources per cluster
Isolated security and access control at each level
Efficient resource management across multiple teams or projects
The organization shown in the Atlas interface reflects this multi-tiered architecture, enabling teams to effectively manage multiple databases across different clusters while maintaining a clear organizational structure.

megaphone
1. A connection string gets you to a specific **CLUSTER** (not project) within a project. Looking at the image, we can see that Projects contain Clusters.
2. The correct hierarchy is: - Organization (shown as "PROFESSOR" in the image) - Projects (like "Project 0" shown) - Clusters (shown as "1 Cluster") - Databases (contained within clusters)
3. In Mongoose code: - You cannot create clusters through code - clusters must be created through the MongoDB Atlas ADMINISTRATION interface ​ - Your connection string connects to an existing cluster: and is generated at the level of the cluster. - Within that cluster connection, you can create and manage multiple databases - Each database can contain multiple collections

Here's an example of the connection flow: // Connection string points to a specific cluster const uri = "mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/";
xxxxx is the cluster identifier.
// Connect to different databases within that cluster const db1 = mongoose.createConnection(`${uri}database1`); const db2 = mongoose.createConnection(`${uri}database2`);
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.