0
0
MongoDBquery~20 mins

Atlas connection string setup in MongoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Atlas Connection Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the correct format of a MongoDB Atlas connection string?
Given the following connection string, what is the expected output when trying to connect to the database?

mongodb+srv://user:password@cluster0.mongodb.net/myFirstDatabase?retryWrites=true&w=majority

Assume the credentials are correct and the cluster is accessible.
AConnection established successfully to the 'myFirstDatabase' database.
BSyntax error due to missing port number in the connection string.
CConnection established but to the default 'admin' database instead of 'myFirstDatabase'.
DConnection fails because 'retryWrites' is not a valid parameter.
Attempts:
2 left
💡 Hint
Look carefully at the connection string format and parameters.
📝 Syntax
intermediate
2:00remaining
Identify the syntax error in this Atlas connection string
Which option contains a syntax error that will prevent connection to MongoDB Atlas?
Amongodb+srv://user:password@cluster0.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
Bmongodb+srv://user:password@cluster0.mongodb.net/myFirstDatabase?retryWrites=true&w=majority&ssl=true
Cmongodb+srv://user:password@cluster0.mongodb.net/myFirstDatabase?retryWrites=true&w=majority&
Dmongodb+srv://user:password@cluster0.mongodb.net/myFirstDatabase
Attempts:
2 left
💡 Hint
Check the query parameters and their separators.
🧠 Conceptual
advanced
2:00remaining
Why is the port number omitted in MongoDB Atlas connection strings using 'mongodb+srv'?
Select the correct reason why Atlas connection strings with 'mongodb+srv' do not include a port number.
ABecause the SRV record in DNS automatically provides the host and port information.
BBecause Atlas only supports connections on the default MongoDB port 27017.
CBecause the port number is included in the username field instead.
DBecause the driver ignores port numbers when using 'mongodb+srv'.
Attempts:
2 left
💡 Hint
Think about how DNS SRV records work.
🔧 Debug
advanced
2:00remaining
Why does this connection string fail to connect to Atlas?
Given this connection string:

mongodb+srv://user:password@cluster0.mongodb.net/?retryWrites=true&w=majority

Why might the connection fail even if credentials are correct?
ABecause the protocol should be 'mongodb' not 'mongodb+srv'.
BBecause 'retryWrites' is set to true which is not supported.
CBecause the password is missing in the connection string.
DBecause the database name is missing after the cluster address.
Attempts:
2 left
💡 Hint
Check if the database to connect to is specified.
optimization
expert
2:00remaining
Optimizing Atlas connection string for read preference
Which connection string option correctly sets the read preference to 'secondaryPreferred' for better read scalability?
Amongodb+srv://user:password@cluster0.mongodb.net/myDB?read_preference=secondaryPreferred
Bmongodb+srv://user:password@cluster0.mongodb.net/myDB?readPreference=secondaryPreferred
Cmongodb+srv://user:password@cluster0.mongodb.net/myDB?readPreference=secondary_preferred
Dmongodb+srv://user:password@cluster0.mongodb.net/myDB?readPreference=secondaryPreferred=true
Attempts:
2 left
💡 Hint
Check the exact parameter name and value format.