Question1: Given a movies collection where each document has the following structure: { _id: ObjectId('573a1390f29313caabcd60e4'), genres: [ 'Short', 'Comedy', 'Drama' ], title: 'The Immigrant', year: 1917, imdb: { rating: 7.8, votes: 4680, id: 8133 }, countries: [ 'USA' ] } Which of the following queries will find all the movies that have more votes than the year in which they were released?
Question2: Suppose we have database with the following collections: db.users.insertMany([ { _id: 1, user_name: 'karo243', account_id: 1010 }, { _id: 2, user_name: 'jano23', account_id: 3213 }, { _id: 3, user_name: 'fac_data', account_id: 4336 } ]) db.accounts.insertMany([ { account_id: 1010, type: 'investment', limit: 1000000 }, { account_id: 4336, type: 'derivatives', limit: 100000 } ]) We want to perform so-called left join. To the users collection join account details from accounts collection based on account_id field. See below. Expected output: [ { _id: 1, user_name: 'karo243', account_id: 1010, account_details: [ { _id: ObjectId("61af47c6e29861661d063714"), account_id: 1010, type: 'investment', limit: 1000000 } ] }, { _id: 2, user_name: 'jano23', account_id: 3213, account_details: [] }, { _id: 3, user_name: 'fac_data', account_id: 4336, account_details: [ { _id: ObjectId("61af47c6e29861661d063715"), account_id: 4336, type: 'derivatives', limit: 100000 } ] } ]
Which query do you need to use?
Question3: Suppose you have a sales collection with the following document structure: { _id: ObjectId("5bd761dcae323e45a93ccfe8"), saleDate: ISODate("2015-03-23T21:06:49.506Z"), items: [ { name: 'printer paper', tags: [ 'office', 'stationary' ], price: Decimal128("40.01"), quantity: 2 } { name: 'pens', tags: [ 'writing', 'office', 'school', 'stationary' ], price: Decimal128("56.12"), quantity: 5 }, { name: 'notepad', tags: [ 'office', 'writing', 'school' ], price: Decimal128("18.47"), quantity: 2 } ], storeLocation: 'Denver', couponUsed: true, purchaseMethod: 'Online' } Which operator should you use to extract all sales documents that have 'notepad' name in items field?
Question4: You have the following replica set configuration: conf = { "_id": "replset", "version": 1, "protocolVersion": 1, "members": [ { "_id": 0, "host": "192.168.120.24:27017", "priority": 2, "votes": 1 }, { "_id": 1, "host": "192.168.120.24:27018", "priority": 1, "votes": 1 }, { "_id": 1, "host": "192.168.120.24:27019", "priority": 1, "votes": 1 } ] } Select all true statements about this configuration.
Question5: Which of the following commands will successfully insert exactly two new documents into an empty companies collection?
Question6: Which of the following scenarios is best suited for applying the Attribute Pattern?
Question7: Select true statements about the selection of the shard key.
Question8: Which of the following roles provides the same read-only privileges as read role on all databases except local and config?
Question9: Why is high cardinality important when choosing a shard key?
Question10: Consider the following command: $ mongod --dbpath /data/db --logpath /data/logs --replSet REPL1 --bind_ip '127.0.0.1,192.168.168.84' -- keyFile /data/keyfile --fork Which of the following configuration files is equivalent to the specified command?
Question11: Select true statements about shard keys.
Question12: What is a document in MongoDB?
Question13: There is a gamers collection in your database with the following document structure: { _id: 1, level: 15, is_active: true }, { _id: 2, level: 14, is_active: true }, { _id: 3, level: 7, is_active: false } How do you increase the value of the level field by 20 for a player with id = 3?
Expected result:
{ _id: 1, level: 15, is_active: true }, { _id: 2, level: 14, is_active: true }, { _id: 3, level: 27, is_active: false }
Question14: Select all true statements about one-to-zillions relationships (a special case of the one-to-many relationship in MongoDB).
Question15: What stages will cause a merge on the primary shard for a database?
Question16: Suppose you have a movies collection with the following document structure:
{ _id: ObjectId("573a1390f29313caabcd60e4"), title: 'The Immigrant', fullplot: "Charlie is on his way to the USA.
He wins in a card game, puts the money in Edna's bag (she and her sick mother have been robbed of everything).
When he retrieves a little for himself he is accused of being a thief.
Edna clears his name. Later, broke, Charlie finds a coin and goes into a restaurant." }
You want to perform text search queries on fullplot field.
What do you have to do? Just query the database. For example:
Question17: Suppose you added the following index to a products collection: { product_category: 1 } Which of the following operations can potentially decrease performance?
Question18: Given a movies collection where each document has the following structure: { _id: ObjectId("573a1390f29313caabcd60e4"), genres: [ 'Short', 'Comedy', 'Drama' ], title: 'The Immigrant', year: 1917, imdb: { rating: 7.8, votes: 4680, id: 8133 }, countries: [ 'USA' ] } Which of the following queries will find all movies that do not contain the Comedy and Romance genres?
Question19: You have the following config file: storage: dbPath: /data/db systemLog: destination: file path: /var/log/mongod.log net: bindIp: localhost,192.168.168.62 security: keyFile: /var/pki/keyfile processManagement: fork: true Select all the directories that MongoDB must have access to
Question20: Select true statements about data modeling in MongoDB.
Question21: Which of the following processes are heavily reliant on available CPU?
Question22: Can you create a unique index in MongoDB?
Question23: A collection called players contains documents with the following structure: { _id: 1, user: 'Tom', scores: [ 23, 56, 3, 52, 62 ], bonus: 5 } { _id: 2, user: 'Jane', scores: [ 42, 50, 10 ], bonus: 3 } You have the following query: db.players.aggregate([{ $addFields: { total_score: { $sum: '$scores' }, avg_score: { $avg: '$scores' } } }, { $addFields: { total_score_with_bonus: { $add: ['$total_score', '$bonus'] } } }, { $match: { bonus: { $gt: 4 } } }]) How can you optimize this query?
Question24: You have the following index in a movies collection: { "title": 1, "imdb.rating": -1, "imdb.votes": -1, "type": 1 } Can the following query use the given index for both filtering and sorting?
db.movies.find( { "title": { "$lt": "M" } } ).sort( { "imdb.votes": -1 } )
Question25: Suppose you have a mobile_games collection with the following document structure:
{ game: "Fishing Clash", company: "Ten Square Games", platforms: ['Android', 'IOS'], ...
release_USA: ISODate("2017-04-09T01:00:00+01:00"),
release_France: ISODate("2017-04-09T01:00:00+01:00"),
release_Italy: ISODate("2017-08-17T01:00:00+01:00"), ... }
You want to redesign your document structure as below:
{ game: "Fishing Clash", company: "Ten Square Games", platforms: ['Android', 'IOS'],
releases: [ { location: "USA", date: ISODate("2017-04-09T01:00:00+01:00") },
{ location: "France", date: ISODate("2017-04-09T01:00:00+01:00") },
{ location: "Italy", date: ISODate("2017-08-17T01:00:00+01:00") }, ], }
Which pattern solution will you use to solve this problem?
Question26: Select all true statements regarding to replication in MongoDB.
Question27: You have a developers collection with the following document structure: { _id: 1, fname: 'John', lname: 'Smith', tech_stack: ['sql', 'git', 'python', 'linux', 'django', 'aws'] }, { _id: 2, fname: 'Michael', lname: 'Doe', tech_stack: [ 'git', 'python', 'sqlite', 'linux', 'flask' ] } Which of the following queries will return only the first three elements of the array in the tech_stack field?
Question28: The $sortByCount stage is equivalent to:
Question29: Select all true statements about MongoDB documents.
Question30: Select all true statements regarding to the _id field in MongoDB documents. (select 4)
Question31: Select all true statements about chunks in MongoDB.
Question32: We have an accounts collection with the following document structure:
{ _id: ObjectId("61af47c6e29861661d063714"), account_id: 1010, type: 'investment', limit: 1000000 }
And the following query:
db.accounts.find({ "$or": [ { "type": { "$in": [ "investment", "derivatives" ] } }, { "limit": { "$gt": 500000 } } ] })
Which of the documents below will be retrieved by this query?
Question33: Which cursor method should you use to get information about the query plan?
Question34: You have the following index in a movies collection: { "title": 1, "imdb.rating": -1, "imdb.votes": -1, "type": 1 } Can the following query use the given index for both filtering and sorting?
db.movies.find( { "title": "James Bond", "imdb.rating": { "$gt": 8} } ).sort( { "imdb.rating": 1 } )
Question35: Which of the following commands can you use to exports data in BSON format from a MongoDB cluster?
Question36: In your database there is a collection named sales with the following document structure: { _id: ObjectId("5bd761dcae323e45a93ccfe8"), saleDate: ISODate("2015-03-23T21:06:49.506Z"), items: [ { name: 'printer paper', tags: [ 'office', 'stationary' ], price: Decimal128("40.01"), quantity: 2 }, { name: 'notepad', tags: [ 'office', 'writing', 'school' ], price: Decimal128("35.29"), quantity: 2 }, { name: 'pens', tags: [ 'writing', 'school', 'stationary' ], price: Decimal128("56.12"), quantity: 5 } ], storeLocation: 'Denver', customer: { gender: 'M', age: 42, email: '[email protected]', satisfaction: 4 }, purchaseMethod: 'Online' } { _id: ObjectId("5bd761dcae323e45a93ccfe9"), saleDate: ISODate("2015-08-25T10:01:02.918Z"), items: [ { name: 'binder', tags: [ 'school', 'general', 'organization' ], price: Decimal128("28.31"), quantity: 9 }, { name: 'backpack', tags: [ 'school', 'travel', 'kids' ], price: Decimal128("83.28"), quantity: 2 } ], storeLocation: 'Seattle', customer: { gender: 'M', age: 50, email: '[email protected]', satisfaction: 5 }, couponUsed: false, purchaseMethod: 'Phone' } How can you extract all documents from this collection where the first tag in the tags field (Array) is 'office' in at least one item?
Question37: In your database there is a collection named companies with the following document structure: { name: 'Wize', relationships: [ { is_past: false, title: 'Head of Product', person: { first_name: 'Ethan', last_name: 'Smith', permalink: 'ethan-smith' } }, { is_past: true, title: 'Director, Business Development', person: { first_name: 'Stephanie', last_name: 'Quay', permalink: 'stephanie-quay' } }, { is_past: true, title: 'Sr. Engineer', person: { first_name: 'Stefan', last_name: 'Antonowicz', permalink: 'stefan-antonowicz' } } ] } Which of the following queries should you use to extract all companies that have "Co-Founder" title in relationships field (Array)?
Question38: Suppose you have a developers collection with the following document structure: { _id: 1, fname: 'Bob', lname: 'Smith', tech_stack: [ 'git', 'c++', 'sqlite', 'linux' ] } Select a query that can be executed without errors.
Question39: Which of the following roles provides minimal privileges needed for backing up data in MongoDB?
Question40: Select all true statements about the update operation. (select 2)
Question41: In your database there is a movies collection with the following document structure: { _id: ObjectId("573a1390f29313caabcd42e8"), genres: [ 'Short', 'Western' ], title: 'The Great Train Robbery', rated: 'TV-G', year: 1903, imdb: { rating: 7.4, votes: 9847, id: 439 }, countries: [ 'USA' ] }, { _id: ObjectId("573a1390f29313caabcd4323"), genres: [ 'Short', 'Drama', 'Fantasy' ], rated: 'UNRATED', title: 'The Land Beyond the Sunset', year: 1912, imdb: { rating: 7.1, votes: 448, id: 488 }, countries: [ 'USA' ] } In some documents, where there is no rating information for movie, the value is set to '' (empty string). With that in mind, which of the following queries will return the title and rating (see below) of top 3 rated movies in this collection?
Question42: Select all true statements regarding to $out stage.
Question43: Suppose you want to familiarize with a new collection and want to display a single document. Which collection method should you use in this case?
Question44: Given the following example document from an artists collection: { _id: 5, last_name: 'Maurer', first_name: 'Alfred', year_born: 1868, year_died: 1932, nationality: 'USA' } and the following index: db.artists.createIndex( { "last_name": 1, "nationality": 1 } ) How MongoDB will handle the query below?
db.artists.find( { "year_born": 1863 } )
Question45: We have a movies collection with the following document structure: { _id: ObjectId("573a1390f29313caabcd6223"), genres: [ 'Comedy', 'Drama', 'Family' ], title: 'The Poor Little Rich Girl', released: ISODate("1917-03-05T00:00:00.000Z"), year: 1917, imdb: { rating: 6.9, votes: 884, id: 8443 } }, { _id: ObjectId("573a13e3f29313caabdc08a4"), genres: [ 'Horror', 'Thriller' ], title: 'Mary Loss of Soul', year: 2014, imdb: { rating: '', votes: '', id: 2904798 } } We need to use Aggregation Framework to calculate the following aggregates: -> average imdb rating -> minimum imdb rating -> maximum imdb rating Expected output: [ { _id: null, avg_rating: 6.6934040649367255, min_rating: 1.6, max_rating: 9.6 } ] Please note that some documents have "" (empty string) for the field "imdb.rating". Exclude these documents before aggregation. Which pipeline should you use?
Question46: There is a collection named products in MongoDB database. Your coworker wants to know how many products are in this collection (number of documents in the collection).
Which query should you use? (select 2)
Question47: You have the following configuration file: net: bindIp: localhost port: 27000 security: authorization: enabled.
You have to edit this file to use new directory as the dbPath: /var/mongodb/db Select correct Answer .
Question48: What does IOPS stand for in database terminology?
Question49: Which of the following operations can be used to access the logs? (Mongo shell)
Question50: Select true statements about capped collections.
Question51: Which of the following commands will delete a collection named restaurants?
Question52: In which situations can we consider sharding?
Question53: We have a movies collection with the following document structure: { _id: ObjectId("573a1390f29313caabcd6223"), genres: [ 'Comedy', 'Drama', 'Family' ], title: 'The Poor Little Rich Girl', released: ISODate("1917-03-05T00:00:00.000Z"), year: 1917, imdb: { rating: 6.9, votes: 884, id: 8443 } } We need to extract all movies from this collection where genres includes both 'Crime' and 'Mystery'. Which query should we use?
Question54: Suppose you have a mobile_games collection with the following document structure: { game: "Fishing Clash", company: "Ten Square Games", platforms: ['Android', 'IOS'], ... release_USA: ISODate("2017-04-09T01:00:00+01:00"), release_France: ISODate("2017-04-09T01:00:00+01:00"), release_Italy: ISODate("2017-08-17T01:00:00+01:00"), ... } Are there any problems with this document structure?
Question55: Select true statements about unique compound indexes.
Question56: We have a restaurants collection with the following document structure: { _id: ObjectId("5eb3d668b31de5d588f42a7d"), address: { building: '605', coord: [ -74.0060152, 40.7372653 ], street: 'Hudson Street', zipcode: '10014' }, cuisine: 'French', grades: [ { date: ISODate("2014-06-30T00:00:00.000Z"), grade: 'A', score: 10 }, { date: ISODate("2013-05-20T00:00:00.000Z"), grade: 'A', score: 13 }, { date: ISODate("2012-12-11T00:00:00.000Z"), grade: 'A', score: 9 } ], name: 'La Ripaille Restaurant' } We need to use Aggregation Framework to calculate the total number of restaurants for top 5 cuisine (sorted in descending order by the number of restaurants). Expected output: [ { _id: 'American', total_restaurants: 6183 }, { _id: 'Chinese', total_restaurants: 2418 }, { _id: 'Cafao/Coffee/Tea', total_restaurants: 1214 }, { _id: 'Pizza', total_restaurants: 1163 }, { _id: 'Italian', total_restaurants: 1069 } ] Which pipeline should you use?
Question57: What command can you use to create a capped collection named latest_news that will be limited to 3 documents and 10,000 bytes?
Question58: Given a companies collection where each document has the following structure: { _id: ObjectId("52cdef7c4bab8bd675297efd"), name: 'ZoomInfo', homepage_url: 'http://www.zoominfo.com', blog_url: 'http://zoominfoblogger.wordpress.com/', twitter_username: 'ZoomInfo', founded_year: 2000, email_address: '' } Extract all companies from this collection that have the same Twitter username as the company name. Which query should you use?
Question59: What is the built-in database called admin in MongoDB for?
Question60: Is MongoDB a NoSQL database?
Question61: Which collection method do you need to use to drop a specific collection?
Question62: We have a movies collection with the following document structure: { _id: ObjectId("573a1390f29313caabcd6223"), genres: [ 'Comedy', 'Drama', 'Family' ], title: 'The Poor Little Rich Girl', released: ISODate("1917-03-05T00:00:00.000Z"), year: 1917, imdb: { rating: 6.9, votes: 884, id: 8443 } } We need to extract all 'Crime' movies from this collection. Which query should we use? Check all that apply.
Question63: There are some special databases in MongoDB that we cannot use to create a new database. Select those names.
Question64: Where is collection metadata stored in a sharded cluster?
Question65: Given a movies collection where each document has the following structure: { _id: ObjectId("573a1391f29313caabcd9264"), genres: [ 'Romance', 'Drama' ], title: 'The Divorcee', languages: [ 'English', 'French' ], year: 1930, imdb: { rating: 6.9, votes: 1740, id: 20827 }, countries: [ 'USA' ] } Which of the following queries will find all movies that have exactly 5 languages?
Question66: We have an accounts collection with only one document: { _id: 54657, account_id: 557378, products: [ 'InvestmentStock', 'Commodity', 'CurrencyService' ] } We need to use Aggregation Framework to unwind the products Array to obtain new documents with only one product per document (see below). Expected output: [ { _id: 54657, account_id: 557378, products: 'InvestmentStock' }, { _id: 54657, account_id: 557378, products: 'Commodity' }, { _id: 54657, account_id: 557378, products: 'CurrencyService' } ] Which pipeline should you use?
Question67: Suppose we have a products collection with the following fields and values: _id (automatically created ObjectId) product_code (unique values for each product) color (as String values) size (this field is missing for some products) origin_country Which of these fields would be the best shard key?
Question68: Given a companies collection where each document has the following structure:
{ _id: ObjectId('61a8b90c6d5ce6a7d8fef95e'), name: 'Facebook', tag_list: ['facebook', 'college', 'students', 'network'], description: 'Social network' }
Which of the following commands will add new fields to the updated documents?
Question69: Assign typical operational tasks to the Database Administrator.
Question70: A collection called players contains the following documents:
[ { _id: 1, user: 'Tom', scores: [ 23, 56, 3, 52, 62 ], bonus: 5 }, { _id: 2, user: 'Jane', scores: [ 42, 50, 10 ], bonus: 3 } ]
You want to add additional fields to each document:
-> total_score (sum of the scores Array) -> avg_score (average score in scores Array) -> total_score_with_bonus (total_score + bonus) Expected output: [ { _id: 1, user: 'Tom', scores: [ 23, 56, 3, 52, 62 ], bonus: 5, total_score: 196, avg_score: 39.2, total_score_with_bonus: 201 }, { _id: 2, user: 'Jane', scores: [ 42, 50, 10 ], bonus: 3, total_score: 102, avg_score: 34, total_score_with_bonus: 105 } ]
Which query do you need to use?
Question71: Suppose you have a developers collection with only two documents:
{ _id: 1, lname: 'Smith', tech_stack: [ 'sql', 'git', 'python', 'django' ], fname: 'Bob' }, { _id: 2, fname: 'Michael', lname: 'Doe', tech_stack: [ 'git', 'python', 'sqlite', 'linux', 'flask' ] }
Using Aggregation Framework you run the following stage:
{ $unwind: { path: '$tech_stack' } }
How many documents will you have in the pipeline after the $unwind stage?
Question72: How to create a new user with the root role named root_user with password root123?
Question73: How to display MongoDB configuration file from command line?
Question74: How to connect to mongod instance and authenticate as root?
Question75: You have the following query: db.gamers.find( { "level": { "$gte" : 70 }, "map": "Inferno" } ).sort( { "points": 1, "group": 1 } ) Which of the following indexes best supports this query? Keep in mind the equality, sort, range rule.
Question76: Suppose you have a companies collection in your database. Only the following documents are stored in this collection:
{ _id: ObjectId("52cdef7c4bab8bd675297da4"), name: 'Powerset', category_code: 'search', founded_year: 2006 }, { _id: ObjectId("52cdef7c4bab8bd675297da5"), name: 'Technorati', category_code: 'advertising', founded_year: 2002 }, { _id: ObjectId("52cdef7c4bab8bd675297da7"), name: 'AddThis', category_code: 'advertising', founded_year: 2004 }, { _id: ObjectId("52cdef7c4bab8bd675297da8"), name: 'OpenX', category_code: 'advertising', founded_year: 2008 }, { _id: ObjectId("52cdef7c4bab8bd675297daa"), name: 'Sparter', category_code: 'games_video', founded_year: 2007 }, { _id: ObjectId("52cdef7c4bab8bd675297dac"), name: 'Veoh', category_code: 'games_video', founded_year: 2004 }, { _id: ObjectId("52cdef7c4bab8bd675297dae"), name: 'Thoof', category_code: 'web', founded_year: 2006 }
How many documents will be deleted when executing the following query?
db.companies.deleteMany( { "category_code": "advertising" } )
Question77: Suppose you have a sales collection with the following document structure: { _id: ObjectId("5bd761dcae323e45a93ccfe8"), saleDate: ISODate("2015-03-23T21:06:49.506Z"), items: [ { name: 'printer paper', tags: [ 'office', 'stationary' ], price: Decimal128("40.01"), quantity: 2 } { name: 'pens', tags: [ 'writing', 'office', 'school', 'stationary' ], price: Decimal128("56.12"), quantity: 5 }, { name: 'notepad', tags: [ 'office', 'writing', 'school' ], price: Decimal128("18.47"), quantity: 2 } ], storeLocation: 'Denver', couponUsed: true, purchaseMethod: 'Online' } Which of the following queries will return all document sales with 'printer paper' sold?
Question78: Select all true statements about elections (replica set).
Question79: Which of the following read preference options may not result in out-of-date data?
Question80: Select all true statements regarding to pipelines and the Aggregation Framework.
Question81: Why adding indexes may lead to slower write operations?
Question82: Given the following example document from an artists collection: { _id: 5, last_name: 'Maurer', first_name: 'Alfred', year_born: 1868, year_died: 1932, nationality: 'USA' } and the following index: db.artists.createIndex( { "last_name": 1, "nationality": 1 } ) How MongoDB will handle the query below?
db.artists.find( { "last_name": /^B./, "nationality": 'France' } )
Question83: In your database there is a collection named trips with the following document structure: { '_id': ObjectId("572bb8222b288919b68abf6d"), 'trip_duration': 858, 'start_station id': 532, 'end_station_id': 401, 'bike_id': 17057, 'start_station_location': { type: 'Point', coordinates: [ -73.960876, 40.710451 ] }, 'end_station_location': { type: 'Point', coordinates: [ -73.98997825, 40.72019576 ] }, 'start_time': ISODate("2016-01-01T00:09:31.000Z"), 'stop_time': ISODate("2016-01-01T00:23:49.000Z") } How can you extract all trips from this collection ended at stations that are to the west of the -73.5 longitude coordinate?
Question84: Given a movies collection where each document has the following structure: { _id: ObjectId("573a1390f29313caabcd60e4"), genres: [ 'Short', 'Comedy', 'Drama' ], title: 'The Immigrant', year: 1917, imdb: { rating: 7.8, votes: 4680, id: 8133 }, countries: [ 'USA' ] } Which of the following queries will find all Comedy movies that were made in 2000? (select 2)
Question85: Given a movies collection where each document has the following structure: { _id: ObjectId('573a1390f29313caabcd60e4'), genres: [ 'Short', 'Comedy', 'Drama' ], title: 'The Immigrant', year: 1917, imdb: { rating: 7.8, votes: 4680, id: 8133 }, countries: [ 'USA' ] } Which of the following queries will find all movies that were made in 2000 or 2010?