0
0
MongoDBquery~20 mins

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

Choose your learning style9 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.