0
0
MongoDBquery~10 mins

Atlas data federation concept in MongoDB - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Atlas data federation concept
User Query Sent
Atlas Data Federation Receives Query
Identify Data Sources
Query Each Source
Aggregate Results
Return Combined Data to User
The flow shows how a user query is sent to Atlas Data Federation, which identifies data sources, queries them, aggregates results, and returns combined data.
Execution Sample
MongoDB
db.users.aggregate([
  { $match: { status: "active" } },
  { $project: { name: 1, email: 1 } }
])
This query filters active users and projects only their name and email from federated data sources.
Execution Table
StepActionData SourceQuery PartResult
1Receive user queryN/AMatch status: activeQuery accepted
2Identify data sourcesSource A, Source BN/ASources identified
3Send query to Source ASource AMatch status: active3 matching documents
4Send query to Source BSource BMatch status: active2 matching documents
5Aggregate resultsN/ACombine documents5 documents combined
6Project fieldsN/ASelect name, email5 documents with name and email
7Return results to userN/AN/A5 documents returned
💡 All sources queried and results combined; query completed successfully.
Variable Tracker
VariableStartAfter Step 3After Step 4After Step 5Final
results[][3 docs from Source A][3 docs + 2 docs][5 combined docs][5 docs with projected fields]
Key Moments - 3 Insights
How does Atlas Data Federation know which data sources to query?
It identifies relevant data sources based on the query and configured federated collections, as shown in Step 2 of the execution_table.
Are queries run on all data sources at once or one by one?
Queries are sent to each data source individually but can happen in parallel; Steps 3 and 4 show querying Source A and Source B separately.
How are results combined from different sources?
Results from each source are aggregated into a single combined set before projection and return, as shown in Step 5.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what happens at Step 4?
AUser query received
BResults aggregated from all sources
CQuery sent to Source B to match active status
DFields projected to name and email
💡 Hint
Check the 'Action' and 'Data Source' columns at Step 4 in execution_table.
At which step are the results combined from all sources?
AStep 5
BStep 3
CStep 7
DStep 2
💡 Hint
Look for 'Aggregate results' action in the execution_table.
If Source B had no matching documents, how would the 'results' variable change after Step 4?
AIt would contain documents from Source B only
BIt would contain only documents from Source A
CIt would be empty
DIt would contain documents from both sources
💡 Hint
Refer to variable_tracker and consider what happens if Source B returns zero documents.
Concept Snapshot
Atlas Data Federation lets you query multiple data sources as one.
You send a query to Atlas, it finds sources, queries each, and combines results.
You get unified data without moving it.
Useful for querying across MongoDB Atlas, S3, and more.
Supports filtering, projection, and aggregation across sources.
Full Transcript
Atlas Data Federation allows users to run a single query that accesses multiple data sources. The process starts when the user sends a query. Atlas Data Federation receives it and identifies which data sources are relevant. It then sends the query to each source separately. Each source returns matching documents. These results are aggregated into one combined set. Finally, the combined data is projected to include only requested fields and returned to the user. This lets users work with data from different places as if it were one database, without moving or copying data.