New Features & Tools in MongoDB 4.0 ALL Question & Answers

We will discuss all chapters of MongoDB University: New Features and Tools in MongoDB 4.0 in this article. By practising all the sets, you can increase your confidence.

Chapter 1 – Replica Set Transactions Quizzes and Answers
 
 

Introduction to Replica Set Transactions

Problem:
Which of the following statements are true about MongoDB Replica Set Transactions?
  • Transactions work across Replica Set clusters.
  • Transactions only work with standalone mongod instances.
  • With transactions in MongoDB, schema design is no longer relevant.
  • Prior to transactions, MongoDB was not able to guarantee ACID operations over single document operations.
 

Transaction Considerations

Problem:
Which of the following are true in the case of multi-document transaction operations?
  • You can only read up to 1000 documents in a transaction.
  • If a transaction takes more than 60 seconds to complete, it will abort.
  • WiredTiger can proactively evict snapshots and abort transactions if cache pressure thresholds are reached.
  • In cases where there is a significant amount of write operations in one single transaction (more than 1000 changed documents), the transaction should be broken into smaller sets of operations.
 

Write Conflicts

Problem:
Which of the following statements are correct?
  • Transaction writes cannot be retried.
  • Reads can still occur while a write lock is taken.
  • All writes not in a transaction context will be applied before the transaction write lock are released.
  • All writes not in a transaction context will fail while a transaction is taking place.
 

Abort vs Commit

Problem:
What can cause TransientTransactionError to occur?
  • Network failures
  • Out-of-memory error
  • WriteConflict errors
  • Stack overflow error
  • Null pointer exception
Chapter 2 – Sharding Improvements Quizzes and Answers
 
 
 

Sharding: Logging of Slow Queries and Sharded Kill on mongos

Problem:
Which of the following are true about the sharded kill command?
  • Kills all the mongos processes of the sharded cluster
  • Kills all cursors currently open in the mongos on which it is run
  • Allows administrators to kill sessions only on the mongod on which it is run
  • Allows administrators to kill operations in the mongos that spawn into individual shards
  • All of the above
 

Sharding: Latency improvements on Secondary Reads

Problem:
Which of the following statements are true as a result of the replication improvements in MongoDB 4.0?
  • You need to modify your application code to benefit from the improvements
  • Writes with a concern of majority on the Primary are acknowledged faster
  • Reads on Secondaries are not blocked while Oplog entries are appliedNew Features and Tools in MongoDB 4.0
Chapter 3 – Misc Server Improvements Quizzes and  Answers
 
 

TLS 1.2 Support

Problem:
Which of the following are true of TLS 1.2?
  • Your data should be securely encrypted in transit to prevent unauthorized access to it via the network.
  • TLS certificates can be used as a means of securely confirming the identity of an entity attempting to access your data.
  • Without it, you may fail to meet corporate security policies which can prevent your applications from going into production.
 

Change Stream Improvements

Problem:
Which of the following are improvements were added to Change Streams in MongoDB 4.0?
  • Resume a change stream
  • Listen for changes across a cluster
  • Open a change stream to track update operations only
  • Change Event document provides information on txnNumber
  • Listen for changes in documents across all collections in a database
Chapter 4 – Aggregation Framework Improvements Quizzes and Answers
 
 

Type Conversions – Part 2

Problem:
Which of the following are new Aggregation expressions in MongoDB 4.0?
  • $toInt
  • $rtrim
  • $convert
  • $toObjectId
  • $dateFromString
Chapter 5 – MongoDB Compass Quizzes and Answers
 
 

Compass: Introduction to new Features

Problem:
Which of the following is/are new features in Compass?
  • Read-Only Compass Edition.
  • Aggregation Pipeline Builder.
  • Import and Export from/to JSON and CSV files.
  • Translator of text fields into 100 languages.
  • Export Queries into Programming Language Code.
 

Compass: Aggregation Pipeline Builder

Problem:
What are some features and advantages of using the Aggregation Pipeline Builder versus writing the pipeline with the Mongo Shell?
  • Compass gives you a list of available stage names in a dropdown menu.
  • Compass can save pipelines to edit and use them later.
  • Compass can translate the aggregation pipeline to the SQL equivalent.
  • Compass informs you that a pipeline stage is correctly formed or has syntax errors.
  • With each stage, Compass displays examples of documents produced by the pipeline up to the given stage of the pipeline.New Features and Tools in MongoDB 4.0
Chapter 6: ODBC Driver for BI Connector Quiz Answer
 
 

Using Excel with the ODBC Driver

Problem:
Note: This lab uses Microsoft Excel. If you do not have a license to use MS Excel, you can open the handout in an open-source alternative.
 
Well, now that we’ve discussed the new features in the BI Connector, it’s time to try them out! Using the new ODBC Driver, we can import data directly into a Microsoft Excel spreadsheet.
 
Below are the instructions to do so; you may choose not to use Vagrant, in which case the “Inside Vagrant” steps should be completed on your host machine:
 

Inside Vagrant…

1) Start up a replica set with three nodes.
 
2) Import the dataset /dataset/companies.json into the replica set.
 
3) Start up a mongosqld process with the following flags (mongosqld has been loaded into Vagrant as an executable, and can be run by typing mongosqld from the command line):
  • Use the –addr option to bind it to the IP address 192.168.40.100 (this is necessary in order for the ODBC driver to communicate with the BI Connector while the BIC is running inside Vagrant!)
  • Use the –mongo-uri option to specify the replica set (this must be a valid URI string that specifies the entire replica set – read the docs if you need a refresher!)

On your host machine…

4) If you are using a Linux machine, download iODBC and the companies.json.tgz dataset file.
 
5) Open the ODBC Manager and add a new “System DSN” with the MongoDB UNICODE ODBC and following keywords (your keywords may be different if you change the port where mongosqld is running, or the database of the companies dataset):
  • SERVER: 192.168.40.100
  • PORT: 3307
  • DATABASE: m040
7) Download the Microsoft Excel handout – there should be a sheet called company_calculations with two columns, and a sheet called companies which is empty
8) In the empty sheet called companies, import the data from the companies collection. Do not change any of this data; just return all of the data to the sheet.
 
All the information from the companies dataset should now be present in the Excel sheet companies. Look at the company calculations sheet to verify that you imported all the data successfully; the “Size of Biggest Company” column should now show the number of employees at the largest business in each industry.
 
 
Question 2)
How many employees work at the biggest company in the advertising industry?
 

Answer:  3160

New Features and Tools in MongoDB 4.0

Chapter 7 – Atlas Quiz Answer
 
 

Recent Features – Cloud Providers, Multi Regions, …

Problem:
Which Cloud Provider(s) are supported by Atlas?
  • Red Hat
  • Dropbox
  • Microsoft Azure
  • Amazon Web Services
  • Google Cloud Platform
 

Recent Features – Hosted BI Connector, Upgrading from Free Tier

Problem:
Which of the following statements are not true regarding the use of the BI connector with Atlas?
  • The BI Connector is a Premium capability
  • The BI Connector only works for MongoDB version of 4.0 or greater
  • You can use Excel to connect to a MongoDB database with the BI Connector
  • You can target a secondary node, in order to not disturb the working set on the Primary By using the Atlas-hosted BI connector, you don’t have to start and manage a BI Connector process
 
 

Recent Features – Real Time Panel, CRUD in Atlas UI, …

Problem:
Which of the following statements is not true regarding the use of the Data Explorer in Atlas?
  • You can clone a document
  • You can create collections
  • You can kill a long running query
  • You can insert a document in a collection
  • You can see the indexes of a given collection
 
 

Recent Features – SRV records, Data Migrator, …

Problem:
Which of the following is the new preferred mechanism in MongoDB to specify a connection string, and now supported in Atlas?
  • A SRV DNS record
  • The application IP address
  • A list of mongod hostnames
  • A list of mongos hostnames
  • A list of mongos IP addresses
 
 

Recent Features – Cloud Providers, Multi Regions, …

Problem:
Which of the following are Advanced Security Features supported for clusters managed by Atlas?
  • AWS IAM Roles
  • Database Auditing
  • LDAP Authorization
  • LDAP Authentication
  • Two Factor Authentication
 

Recent Features – Auto Scaling Storage, Performance Advisor

Problem:
Which of the following statements is not true regarding the help Atlas can give you to eliminate problems?
  • Atlas can suggest a different and optimal schema for your documents.
  • The Performance Advisor can recommend indexes for detected slow queries.
  • You can upgrade to an instance with more memory with few clicks and no downtime.
  • You can easily move a replica from one region to another region with no downtime.
  • Atlas can automatically increase the storage capacity if the disks are getting full.
Final Exam Quizzes & Answers
 
  

Final Exam: Replica Set Transactions

Problem:
Consider the following set of operations executing in the mongo shell:
 
use m040
db.a.insert({_id: 1})
s1 = db.getMongo().startSession()
s2 = db.getMongo().startSession()
s1.startTransaction()
s2.startTransaction()
s1.getDatabase("m040").a.find()
s2.getDatabase("m040").a.find()
s1.getDatabase("m040").a.update({_id:1}, {$set: {value: "s1"}})
s1.getDatabase("m040").a.find() // line 10
s2.getDatabase("m040").a.find() // line 11
s2.getDatabase("m040").a.update({_id:1}, {$set: {value: "s2"}})
s1.getDatabase("m040").a.find()
s2.getDatabase("m040").a.find()
s1.abortTransaction()
s2.abortTransaction()
s1.getDatabase("m040").a.find()
s2.getDatabase("m040").a.find() // line 18
 
Which of the following is/are true?
  • WriteConflict occurs on line 12
  • The output of line 18 is { _id: 1, value: “s1” }
  • The output of line 11 is { _id: 1, value: “s2” }
  • The output of line 10 is { _id: 1, value: “s1” }

Final Exam: Sharding

Problem:
Which of the following are new capabilities added in MongoDB 4.0 for sharded cluster administration ?
  • Getting faster chunk migrations
  • Identifying slow queries in the mongos logs
  • Aborting an operation running on many shards
  • Getting faster acknowledgements for writes with concern
    majority

Final Exam: Aggregation

Problem:
Consider this document:
 
{
  _id: 1,
  time: "10/01/2018"
}
 
If we execute the following aggregation:
 
db.collection.aggregate([
  {
    $addFields: {
      time: {
        $dateToParts: {
          date: {
            $dateFromString: {
              dateString:
"$time",
              format:
"%d/%m/%Y"
            }
          }
        }
      }
    }
  },
  {
    $project:{
      time: {
        $dateFromParts: {
          "month": {$add:[-13,
"$time.month"]},
          "year": "$time.year"
        }
      }
    }
  }
])
Which of the following is/are true?
 
Pay attention to the format string in the $addFields stage
  • The year on the date is 2016.
  • The day in the date field is 1st of December.
  • The _id is not present in the output document.
  • The aggregation command fails due to an out-of-bound date.
  • The aggregation command fails with an “Unknown format field
    error”.

Final Exam: Atlas

Problem:
Which of the following statements is/are true regarding features recently added to Atlas?
  • Only AWS supports sharded clusters.
  • Using the Atlas BI connector frees you from maintaining the process locally.
  • You must use the live migrator tool to migrate out of the free
    tier.
  • Atlas allows to keep data in given regions to comply with data governance, like GDPR.
  • In Azure, Atlas supports backups as local snapshots in the region in which the cluster is located.
 

Final Exam: Upgrade & Downgrade

Problem:
Which of the following statements is/are true regarding upgrades to MongoDB 4.0 or downgrades from 4.0?
  • You can downgrade a cluster without downtime
  • You can upgrade a cluster without downtime
  • You can upgrade directly from MongoDB 3.4 to MongoDB 4.0
  • The flag previousVersionCompatibility controls the ability to use
    the new 4.0 features

Leave a Comment