0
0
MongoDBquery~20 mins

Built-in roles (read, readWrite, dbAdmin) in MongoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
MongoDB Role Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:30remaining
What does the read role allow a user to do?
In MongoDB, the read built-in role grants specific permissions. Which of the following best describes what a user with the read role can do?
ARead data from all collections in the database but cannot modify any data.
BRead and write data to all collections in the database.
CManage users and roles for the database.
DRead data and create indexes but cannot write or modify data.
Attempts:
2 left
💡 Hint
Think about what 'read' means in terms of data access.
query_result
intermediate
1:30remaining
What operations can a user with the readWrite role perform?
A user is assigned the readWrite role on a MongoDB database. Which of the following actions can this user perform?
AOnly read data from collections.
BManage database users and roles.
CRead and write data, including inserting, updating, and deleting documents.
DOnly create indexes but cannot modify data.
Attempts:
2 left
💡 Hint
Consider what 'write' implies in addition to 'read'.
query_result
advanced
2:00remaining
Which actions are allowed by the dbAdmin role in MongoDB?
The dbAdmin role provides administrative privileges on a database. Which of the following actions can a user with this role perform?
ARead and write data in collections.
BOnly read data from collections.
CManage users and roles across all databases.
DCreate and drop collections, manage indexes, and view statistics but cannot read or write data.
Attempts:
2 left
💡 Hint
Think about administrative tasks that do not involve data modification.
📝 Syntax
advanced
2:00remaining
Which command correctly grants the readWrite role to a user on the sales database?
You want to grant the readWrite role to user alice on the sales database. Which of the following MongoDB shell commands is correct?
Adb.grantRolesToUser('alice', [{ role: 'readWrite', db: 'sales' }])
Bdb.updateUser('alice', { roles: ['readWrite'] })
Cdb.updateUser('alice', { roles: [{ role: 'readWrite', db: 'sales' }] })
Ddb.grantRolesToUser('alice', ['readWrite'])
Attempts:
2 left
💡 Hint
Check the correct method and format for updating user roles.
🧠 Conceptual
expert
2:30remaining
Why should you avoid assigning the dbAdmin role to users who only need to read and write data?
Consider the security and best practices in MongoDB role assignments. Why is it not recommended to assign the dbAdmin role to users who only need to read and write data?
ABecause <code>dbAdmin</code> does not allow reading or writing data, so users cannot perform their tasks.
BBecause <code>dbAdmin</code> allows managing collections and indexes, which can affect database structure and performance, posing unnecessary risks.
CBecause <code>dbAdmin</code> automatically grants access to all databases, which is a security risk.
DBecause <code>dbAdmin</code> role expires after 24 hours, causing access issues.
Attempts:
2 left
💡 Hint
Think about the principle of least privilege.