Database Foundations- MongoDB 8-12

¡Supera tus tareas y exámenes ahora con Quizwiz!

What is the main difference between $set and $project? (Select one.)

$set is used to create or change values of new or existing fields. $project can be used to create or change the value of fields, but it can also be used to specify which fields to show in the documents in the aggregation pipeline. $set and $project can both create and assign values to fields, but only $project can be used to reshape the data.

Which of the following actions can be made to improve this schema? Consider the following requirements: Preserve the one-to-one relationship among all the fields. Keep the contact and account information separate. Store data together that is accessed together.

. Create two collections: one for accounts and one for customer_info. B. Embed the phone numbers as a subdocument. Embedding the phone numbers as a subdocument can improve the schema, and it ensures that data that is accessed together is stored together.

Which of the following statements is/are true about embedding data in documents? (Select all that apply.)

. Embedding data in documents simplifies queries. Embedding data simplifies queries because it avoids application joins. It fulfills the principle that data that is accessed together should be stored together. B. Embedding data in documents improves the overall performance of queries. Embedding data provides better performance for read operations. Embedded documents enable you to store all kinds of related information in a single document.

Which of the following relationship types often use embedding? (Select all that apply.)

. One-to-one relationship B. One-to-many relationship C. Many-to-many relationship

What will the output ofthis aggregation pipeline be? (Select one.) db.zips.aggregate([ { $group: { "_id": "$pop" } }, { $sort: { _id: -1 } }, { $limit: { 10 } } ])

10 documents, each containing the population of a zip code as the _id, sorted by population in descending order The sort order of the $sort stage is -1, which means that the $sort stage will sort documents in descending order based on population. The $limit stage limits the number of documents that are returned to 10.

Which of the following is the best definition of an ACID transaction? (Select one.)

A group of database operations that must happen all together or not at all. An ACID transaction involves a group of database operations that must happen together successfully or not at all.

What does the $count stage return? (Select one.)

A single document with one field that contains the value set to the number of documents at this stage in the aggregation pipeline. The $count stage returns a document with a field named in the parameters with the value set to the number of documents at this stage in the aggregation pipeline.

What is the maximum number of array fields per multikey index? (Select one.)

A. 1 The maximum number of array fields per multikey index is 1. If an index has multiple fields, only one of them can be an array.

Which of the following are benefits of a proper data model? (Select all that apply.)

A. A proper data model makes it easier to manage your data. B. A proper data model makes queries more efficient. C. A proper data model uses less memory and CPU. D. A proper data model reduces costs.

What type of index is written below? (Select one.) { "analyzer": "lucene.standard", "searchAnalyzer": "lucene.standard", "mappings": { "dynamic": true } }

A. A search index A search index is used to describe how the application search algorithm should work. You can customize this with Atlas Search.

What is a single field index? (Select one.)

A. An index that supports efficient querying against one field A single field index is an index that supports efficient querying against a single field. By default, all collections have a single field index on the _id field, but users can define additional indexes that support important queries. A single field index is also a multikey index if the value of the field is an array.

What does the "filter" clause do? (Select one.)

A. It returns results that match the clause. The "filter" clause returns results that match the clause. It eliminates results that do not match the clause.

What will the output of this aggregation pipeline be? (Select one.) db.zips.aggregate([ { $match: { "state": "TX" } }, { $group: { "_id": "$city" } } ])

A. One document for each city located in Texas (TX) First, the $match stage finds all documents where the state is Texas (TX). Next, the $group stage groups documents according to a group key. The output of this stage is one document for each unique value of this group key. In this example, the output is one document for each city because the group key is the city.

Which of the following are common types of relationships that are found in every database? (Select all that apply.)

A. One-to-one relationship One-to-one is a relationship where a data entity in one set is connected to exactly one data entity in another set. B. One-to-many relationship One-to-many is a relationship where a data entity in one set is connected to any number of data entities in another set. C. Many-to-many relationship A many-to-many relationship is one of the most common types of relationships found in a database. Many-to-many is a relationship where any number of data entities in one set are connected to any number of data entities in another set.

What are the effects of creating unbounded documents when embedding data? (Select all that apply.)

A. Unbounded documents impact write performance. Embedding data will make the document larger and impact write performance. As more data is added to each document, the entire document is rewritten into MongoDB data storage. Unbounded documents cause storage problems. Unbounded documents caused by embedding will eventually run into storage problems by exceeding the maximum document size of 16 MB.

What is the recommended way to avoid the unbounded document sizes that may result from embedding?

A.Break data into multiple collections and use references. To prevent unbounded document sizes that may result from embedding, you can break up your data into multiple collecitons and use references to keep frequently accessed data together.

What is MongoDB's principle for how you should design your data model?

A.Data that is accessed together should be stored together. Data that is accessed together should be stored together. How you model your data depends entirely on your particular application's data access patterns. You want to structure your data to match the ways that your application queries and updates it.

What is the type of relationship shown in the following document? { "_id": ObjectId("00000001"), "name": "Marnie Dupree", "grade": "Freshman", "studentId": 123456, "email": "[email protected]" }

A.One-to-one relationship There is a one-to-one relationship in this document. This is a document for a single student that contains her unique identifying fields.

What is a multikey index? (Select one.)

An index where one of the indexed fields contains an array Multikey indexes support efficient queries against array fields by creating an index key for each element in the array. This allows MongoDB to search for the index key of each element in the array rather than scan the entire array, which results in dramatic performance gains in your queries.

What happens if you set the $out stage to output to a collection that already exists? (Select one.)

The existing collection is erased and replaced with the outputted documents. Users must be careful not to overwrite any collections unintentionally when specifying the name of the collection to output the documents to.

Which of the following statements about indexes are true? (Select one.)

B. Indexes improve query performance at the cost of write performance. Indexes improve query performance at the cost of write performance. For most use cases, this tradeoff is acceptable. Indexes should be used on data that is frequently queried or on queries that are infrequent but costly in terms of computational resources.

If the search index is statically mapped and the only field mapping is for the "storeLocation" field, and you searched for one of the items sold by the office supply company, notepads, how many results will come up? (Select one.)

C. None The only field indexed is the location of the store, so data such as the items sold have not been indexed by the search algorithm. Only queries for names of cities present as values in the storeLocation field will be returned.

If you want to view the metadata (facets and their count) for Atlas Search, which aggregation stage must you use? (Select one.)

B. $searchMeta To view the search metadata (facets and their count), use the $searchMeta stage.

Which type of search is depicted in the image below? (Select one.)

B. Relevance-based search in an application This is a relevance-based search on the MongoDB homepage, where the user searched for "Atlas Search" and the results returned were relevant to that search term.

What is the minimum Atlas Cluster tier that you must have to use the Performance Advisor tool?

B.M10 The Performance Advisor tool is available in M10+ cluster tiers.

When using a dynamic index, which fields does an Atlas Search query against? (Select one.)

C. All of the fields including nested fields. A search with a dynamic index will query against all of the fields, including nested fields.

What is a compound index? (Select one.)

C. An index that contains references to multiple fields within a document A compound index is an index that contains references to multiple fields within a document. Compound indexes are created by adding a comma-separated list of fields and their corresponding sort order to the index definition.

What does the $out stage do? (Select one).

Creates a new collection that contains the documents in this stage of the aggregation pipeline. The $out stage outputs the documents in the aggregation pipeline to a new collection.

Which clauses used by the compound operator contribute to the score given the results? (Select one.)

D. "must", "must not", and "should" "Must", "must not", and "should" are all clauses, but "filter" does not impact the score given to the results.

Which operator can you use to group Atlas search results? (Select one.)

D. facet To group your search results, use the facet operator

Consider the following document from a posts collection, which contains data about a blog post and its comments. Which field is used as a reference? (Select one.)

D. user_id

Which of the following statements is/are true about data modeling? (Select all that apply.)

Data modeling is the process of defining how data is stored. B. Data modeling is the process of defining the relationships that exist among different entities in your data.

Which of the following statements are true about multi-document transactions in MongoDB? (Select all that apply.)

Database operations that affect more than one document, like .updateMany(), are not inherently atomic in MongoDB and must be completed by using a multi-document transaction in order to have ACID properties. B. Multi-document transactions should be treated as a precise tool that is used only in certain scenarios. C. Using a multi-document transaction with a MongoDB database ensures that the database will be in a consistent state after running a set of operations on multiple documents.

What is the recommended order of fields in a compound index? (Select one.)

Equality, Sort, Range The recommended order of indexed fields in a compound index is Equality, Sort, and Range. Optimized queries use the first field in the index, Equality, to determine which documents match the query. The second field in the index, Sort, is used to determine the order of the documents. The third field, Range, is used to determine which documents to include in the result set.

Which of the following tasks cannot be completed with an aggregation pipeline? (Select one.)

Finding data from outside sources

Which of the following statements about indexes are correct? (Select all the that apply.)

Indexes are data structures that improve performance, support efficient equality matches and range-based query operations, and can return sorted results. Indexes are used to make querying faster for users. Indexes achieve this by allowing MongoDB to perform only the work necessary to return the data that is requested, rather than scanning the entire collection. One of the easiest ways to improve the performance of a slow query is create indexes on the data that is used most often. Indexes help make querying faster for users by only scanning the indexes to find the data that is requested.

You create a single field index on the email field, with the unique constraint set to true: db.customers.createIndex({email:1}, {unique:true}) What would happen if you attempt to insert a new document with an email that already exists in the collection? (Select one.)

MongoDB will return a duplicate key error, and the document will not be inserted. Unique indexes ensure that indexed fields do not store duplicate values. In this example, MongoDB will return a duplicate key error if you attempt to insert a new document with an email that already exists in the collection, as the unique constraint was set to true.

Nadia needs to update customer account balances across multiple collections in MongoDB. It's important that the database operations used in this transaction adhere to ACID properties. Should Nadia use a transaction in this scenario? (Select one.)

Nadia does need to use a transaction in this scenario because multi-document operations are NOT inherently atomic in MongoDB. Nadia should use a multi-document transaction in this scenario. Unlike single-document operations, multi-document operations are not inherently atomic in MongoDB. Because the group of database operations will be performed on multiple documents and require ACID properties, they should use a multi-document transaction.

You have a collection that contains zip codes in the United States. Here's a sample document from this collection: _id: ObjectId('5c8eccc1caa187d17ca6eea2') city: "EVERGREEN" zip: "36401" loc: Object y: 31.458009 x: 86.925771 pop: 8556 state: "AL" What will the output of this aggregation pipeline be? (Select one.) db.zips.aggregate([ { $match: { "state": "CA" } }, { $group: { "_id": "$zip" } } ])

One document for each zip code located in California (CA) First, the $match stage finds all documents where the state is California (CA). Next, the $group stage groups documents according to a group key. The output of this stage is one document for each unique value of this group key. In this example, the output is one document for each zip code because the group key is the zip code.

What will the output of this aggregation pipeline be? (Select one.) db.zips.aggregate([ { $group: { "_id": "$pop" } }, { $sort: { _id: -1 } } ])

One document for the population of each zip code, sorted in descending order The $group stage groups documents according to a group key. The output of this stage is one document for each unique value of this group key. In this example, the output is one document per each zip code's population. Each document contains only the population value of each zip as the _id. Next, the $sort stage sorts all input documents and returns them to the pipeline in sorted order. $sort takes a document that specifies in the field(s) to sort by and the respective sort order, 1 for ascending and -1 for descending. In this example, we sorted by population in descending order meaning we return the documents in order based on the largest population.

Which of the following statements is/are true about referencing data in documents? (Select all that apply.)

Referencing data in documents avoids duplication of data. B. Referencing data in documents may result in smaller documents. C. Referencing data in documents links documents by using the same field.

Which tab in Data Explorer shows ways to improve your schemas?

Schema Anti-Patterns The Schema Anti-Patterns tab highlights any issues in the collection and provides details to resolve them. You can improve your schema by resolving the anti-patterns that are shown.

The following code is a snippet from a search index. What type of field mapping does this search index use? (Select one.) { "mappings": { "dynamic": false, "fields": { "common_name": [ { "dynamic": true, "type": "document" }, { "type": "string" } ] } } }

Static Mapping This is a statically-mapped search index. As you can see within "fields" there are specific settings for the "common_name" field. Search indexes with static field mapping are designed to find results from specified fields.

Which of the following is a benefit of the document model?

The document model does not enforce any document structure by default. This means that documents even in the same collection can have different structures.

What are the ramifications of deleting an index that is supporting a query? (Select one.)

The performance of the query will be negatively affected. The performance of the query will be negatively affected by the deletion of the only index that is currently supporting that query. Indexes generally improve the performance and time efficiency of queries by reducing the number of times that the database needs to be accessed.

Which of the following scenarios require the use of an ACID transaction? (Select all that apply.)

Updating a bank database to reflect the transfer of money from Customer A's bank account into Customer B's bank account. B. Updating inventory and shopping cart records when a customer adds an item to their online shopping cart in an ecommerce app. In most scenarios involving the transfer of value, inventory, or ownership of goods, database operations MUST happen atomically. This scenario requires the use of ACID properties to guarantee that both the inventory and shopping cart records are updated together or not at all.

When would you use a dynamically mapped search index? (Select one.)

When you want to search all of the fields with equal weight. Dynamic field mapping is used to search all of the fields for the search term, with equal weight placed on all fields.

Which command performs an aggregation operation by using an aggregation pipeline? (Select one.)

aggregate(). aggregate() performs an aggregation operation by using an aggregation pipeline. aggregate() takes an array of aggregation stages to form the pipeline. An aggregation function is written as db.collection.aggregate().

Which of the following commands will output to the shell if they are successful?

commitTransaction() If it's successful, .commitTransaction() will output a message to the shell that resembles the following: { ok: 1, '$clusterTime': { clusterTime: Timestamp({ t: 1647437775, i: 5 }), signature: { hash: Binary(Buffer.from("b0d88d5a96372efb9af22021cdd59021741ddb5c", "hex"), 0), keyId: Long("7019511514256113665") } }, operationTime: Timestamp({ t: 1647437775, i: 5 }) }

What method should you use to complete this transaction? (Select one.)

commitTransaction() We use .commitTransaction() to commit a transaction.session.commitTransaction() should be placed at the end of the transaction.

You have an index on the email field. Here's the command you used to create the index: db.customers.createIndex({email:1}) Before deleting it, you want to assess the impact of removing this index on the performance of the query. To do this, which command should you use? (Select one.)

hideIndex() The hideIndex() command hides an index. By hiding an index, you'll be able to assess the impact of removing the index on query performance. MongoDB does not use hidden indexes in queries but continues to update their keys. This allows you to assess if removing the index affects the query performance and unhide the index if needed. Unhiding an index is faster than recreating it. In this example, you would use the command db.customers.hideIndex({email:1}).


Conjuntos de estudio relacionados

Intro to Law and Legal System Midterm Review

View Set

Essentials of Systems Analysis and Design

View Set

Wong's Ch. 18: Impact of Cognitive or Sensory Impairment on the Child and Family

View Set

Alexander Zaiko Deca terms for HS test

View Set

Effective Police Supervision 8th Edition - Chapter 7

View Set

Financial Management LS Chapter 6

View Set