Bird
Raised Fist0
MongoDBquery~20 mins

Atlas data federation concept in MongoDB - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Atlas Data Federation Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the primary purpose of Atlas Data Federation?
Atlas Data Federation allows you to query data from multiple sources as if they were one. What is the main benefit of this feature?
AIt automatically backs up your data to multiple regions for disaster recovery.
BIt lets you combine data from different databases and cloud services without moving the data.
CIt encrypts your data at rest and in transit for security compliance.
DIt creates a single database instance that stores all your data physically in one place.
Attempts:
2 left
💡 Hint
Think about how you can access data without copying or moving it.
❓ query_result
intermediate
2:00remaining
What is the output of this Atlas Data Federation query?
Assume you have two collections: users in Atlas cluster and orders in an S3 bucket. You run this query in Atlas Data Federation:
db.users.aggregate([
  { $lookup: {
      from: "orders",
      localField: "user_id",
      foreignField: "user_id",
      as: "user_orders"
  }},
  { $match: { "user_orders.0": { $exists: true } } }
])

What does this query return?
AAn error because $lookup cannot join collections from different data sources.
BAll orders that have a matching user, with user details included in each order document.
CAll users, regardless of orders, with an empty user_orders array for those without orders.
DAll users who have at least one order, with their orders included in the user_orders array.
Attempts:
2 left
💡 Hint
Look at the $match stage filtering on user_orders.0 existence.
📝 Syntax
advanced
2:00remaining
Which option correctly defines a data source in Atlas Data Federation configuration?
You want to add an S3 bucket as a data source in Atlas Data Federation. Which JSON snippet is syntactically correct for this configuration?
A{ name: "myS3Source", type: "s3", config: { "bucket": "my-bucket", "region": "us-east-1" } }
B{ "name": "myS3Source", "type": "s3", "config": { bucket: "my-bucket", region: "us-east-1" } }
C{ "name": "myS3Source", "type": "s3", "config": { "bucket": "my-bucket", "region": "us-east-1" } }
D{ "name": "myS3Source", "type": "s3", "config": { "bucket": "my-bucket" "region": "us-east-1" } }
Attempts:
2 left
💡 Hint
Remember JSON keys and string values must be in double quotes and commas separate items.
❓ optimization
advanced
2:00remaining
How can you optimize queries in Atlas Data Federation when joining large datasets?
You have a query joining a large Atlas collection with a large S3 dataset using $lookup. What is the best way to improve query performance?
AUse $match before $lookup to reduce the number of documents processed in the join.
BIncrease the Atlas cluster size to handle more data during the join.
CUse $project after $lookup to remove unwanted fields from the joined documents.
DSplit the query into two separate queries and join results in application code.
Attempts:
2 left
💡 Hint
Filtering early reduces data processed in joins.
🔧 Debug
expert
2:00remaining
Why does this Atlas Data Federation query fail with a 'NamespaceNotFound' error?
You run this query:
db.sales.aggregate([
  { $match: { amount: { $gt: 100 } } }
])

But get an error: NamespaceNotFound: sales not found. The 'sales' collection exists in your Atlas cluster but not in the S3 bucket data source. Your federation data source includes both Atlas and S3. What is the cause?
AThe query is run against the federation view that does not include the 'sales' collection from Atlas cluster.
BThe 'sales' collection name is misspelled in the query.
CAtlas Data Federation does not support $match on numeric fields.
DThe user running the query lacks read permissions on the 'sales' collection.
Attempts:
2 left
💡 Hint
Check which data sources are included in your federation configuration.

Practice

(1/5)
1. What is the main purpose of MongoDB Atlas Data Federation?
easy
A. To query data from multiple sources as if they were one database
B. To create backups of MongoDB databases automatically
C. To optimize single-node MongoDB performance
D. To convert SQL queries into MongoDB queries

Solution

  1. Step 1: Understand the concept of Atlas Data Federation

    Atlas Data Federation allows querying data from different sources like cloud object stores and databases as a single database.
  2. Step 2: Identify the main purpose

    The main goal is to simplify querying distributed data by treating it as one unified database.
  3. Final Answer:

    To query data from multiple sources as if they were one database -> Option A
  4. Quick Check:

    Atlas Data Federation = Unified querying [OK]
Hint: Think 'one query, many sources' for Atlas Federation [OK]
Common Mistakes:
  • Confusing federation with backup features
  • Thinking it only optimizes single-node performance
  • Assuming it translates SQL queries automatically
2. Which of the following is the correct way to create a federated database in MongoDB Atlas Data Federation?
easy
A. Run a MongoDB shell command: createFederatedDB()
B. Use the Atlas UI to define data sources and create a federated database
C. Install a special MongoDB plugin on your local machine
D. Write a SQL script to link data sources

Solution

  1. Step 1: Recall how federated databases are created

    Atlas Data Federation uses the Atlas web interface to configure data sources and create federated databases.
  2. Step 2: Evaluate the options

    Only the Atlas UI method is correct; there is no shell command or plugin for this, nor SQL scripts.
  3. Final Answer:

    Use the Atlas UI to define data sources and create a federated database -> Option B
  4. Quick Check:

    Federated DB creation = Atlas UI [OK]
Hint: Atlas UI is your tool for federation setup [OK]
Common Mistakes:
  • Trying to create federated DB via shell commands
  • Looking for local plugins instead of cloud setup
  • Using SQL scripts which are not supported
3. Given a federated database combining a MongoDB collection and an S3 bucket, what will the following query return?
db.federatedCollection.find({"type": "image"})
medium
A. Only files from S3 bucket with type 'image'
B. Only documents from MongoDB collection with type 'image'
C. Documents from MongoDB collection and files from S3 with type 'image'
D. An error because S3 data cannot be queried

Solution

  1. Step 1: Understand federated query behavior

    Atlas Data Federation allows querying multiple sources like MongoDB and S3 as one collection.
  2. Step 2: Analyze the query

    The query filters documents/files where the field "type" equals "image" across all federated sources.
  3. Final Answer:

    Documents from MongoDB collection and files from S3 with type 'image' -> Option C
  4. Quick Check:

    Federated query returns combined matching data [OK]
Hint: Federated queries combine all sources transparently [OK]
Common Mistakes:
  • Assuming only MongoDB data is returned
  • Thinking S3 data cannot be queried
  • Expecting an error due to mixed sources
4. You wrote this query on a federated database:
db.federatedCollection.find({"status": "active"})

But it returns no results, even though you know some data has status 'active'. What could be the problem?
medium
A. You must use SQL syntax instead of MongoDB queries
B. The query syntax is invalid for federated databases
C. MongoDB Atlas does not support filtering on 'status' field
D. The federated database was not properly linked to all data sources

Solution

  1. Step 1: Check query correctness

    The query syntax is valid MongoDB syntax and filtering on 'status' is supported.
  2. Step 2: Consider federation setup

    If no results appear, likely the federated database is missing some data sources or not linked properly.
  3. Final Answer:

    The federated database was not properly linked to all data sources -> Option D
  4. Quick Check:

    Missing data sources cause empty results [OK]
Hint: Check federation links if queries return no data [OK]
Common Mistakes:
  • Blaming query syntax instead of setup
  • Thinking Atlas forbids filtering on fields
  • Trying to use SQL syntax in MongoDB queries
5. You want to create a federated database that combines a MongoDB Atlas cluster, an S3 bucket, and a Google Cloud Storage bucket. Which of the following is true about querying this federated database?
hard
A. You can run a single MongoDB query that returns matching data from all three sources
B. You must query each source separately and merge results manually
C. Federation supports only two sources at a time, so you must create two federated databases
D. You can only query MongoDB Atlas data; cloud storage buckets are read-only

Solution

  1. Step 1: Understand multi-source federation

    Atlas Data Federation supports combining multiple data sources including MongoDB Atlas and various cloud storage buckets.
  2. Step 2: Query behavior on federated database

    A single MongoDB query can access and return matching data from all linked sources transparently.
  3. Final Answer:

    You can run a single MongoDB query that returns matching data from all three sources -> Option A
  4. Quick Check:

    Federation = unified multi-source queries [OK]
Hint: Federation lets one query cover many sources [OK]
Common Mistakes:
  • Thinking you must query sources separately
  • Believing federation limits to two sources
  • Assuming cloud buckets are read-only and not queryable
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard