0
0
MongoDBquery~5 mins

Atlas data federation concept in MongoDB

Choose your learning style9 modes available
Introduction

Atlas Data Federation lets you search and query data from many places as if it were all in one spot. This makes it easy to work with data without moving it around.

You want to see data from multiple databases in one query without copying data.
You have data stored in different cloud services and want to combine it easily.
You want to analyze data from files and databases together.
You want to build apps that use data from many sources without complex setup.
Syntax
MongoDB
Use the Atlas UI or API to create a Data Federation service.
Then run queries like:

use <federated_database>
db.<collection>.find({})
Atlas Data Federation works by creating a virtual database that connects to your data sources.
You query the federated database like a normal MongoDB database.
Examples
This queries the 'sales' collection from all connected data sources in the federated database.
MongoDB
use federatedDB
db.sales.find({})
This finds all PDF files across connected storage and databases.
MongoDB
use federatedDB
db.files.find({type: 'pdf'})
Sample Program

This query fetches all active customers from all connected data sources through the federated database.

MongoDB
use federatedDB
// Find all customers with status 'active'
db.customers.find({status: 'active'})
OutputSuccess
Important Notes

Atlas Data Federation supports querying data from MongoDB Atlas clusters, AWS S3 buckets, and more.

It helps avoid data duplication by querying data where it lives.

Summary

Atlas Data Federation lets you query data from many sources as one database.

You use it by creating a federated database and running normal MongoDB queries.

This makes working with distributed data easier and faster.