Unit 6: NoSQLDatabases - Practice Quiz

INT306 — Database Management Systems 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What type of NoSQL database is MongoDB primarily classified as?

Introduction of MongoDB Easy
A. Graph database
B. Document-oriented database
C. Key-value store
D. Column-family store

2 Which data format does MongoDB use internally to store documents?

Introduction of MongoDB Easy
A. BSON
B. CSV
C. YAML
D. XML

3 Amazon DynamoDB is a managed NoSQL database service provided by which cloud platform?

DynamoDB Easy
A. Microsoft Azure
B. Amazon Web Services (AWS)
C. Google Cloud Platform (GCP)
D. IBM Cloud

4 Which of the following describes the primary data models supported by DynamoDB?

DynamoDB Easy
A. Key-value and Document
B. Time-series and Spatial
C. Relational and Graph
D. Columnar and Relational

5 What is the main advantage of using a serverless cloud database?

Serverless cloud database Easy
A. It automatically scales compute and storage based on demand.
B. It only supports SQL queries.
C. You have full root access to the underlying hardware.
D. It requires manual provisioning of servers.

6 How are costs typically calculated for a serverless cloud database?

Serverless cloud database Easy
A. One-time perpetual license
B. Fixed monthly fee regardless of usage
C. Yearly licensing per CPU core
D. Pay-as-you-go based on actual consumption (reads, writes, storage)

7 In the structure of MongoDB, what is the equivalent of a relational database table?

Structure of MongoDB Easy
A. Cluster
B. Collection
C. Document
D. Field

8 In MongoDB, what corresponds to a row in a traditional relational database?

Structure of MongoDB Easy
A. Database
B. Collection
C. Document
D. Index

9 Which of the following is a primary characteristic of NoSQL databases compared to SQL databases?

SQL vs NoSql Easy
A. Rigid, predefined schema
B. Flexible schema design
C. Use of foreign keys for strict referential integrity
D. Always requires ACID compliance for all operations

10 How do NoSQL databases typically scale to handle massive amounts of data?

SQL vs NoSql Easy
A. They cannot scale.
B. Diagonally (only upgrading network speed)
C. Vertically (adding more CPU/RAM to a single server)
D. Horizontally (adding more servers to a distributed system)

11 Which MongoDB command is used to retrieve data from a collection?

Working with MongoDB Easy
A. db.collection.fetch()
B. db.collection.find()
C. db.collection.get()
D. db.collection.select()

12 Which command inserts a single new document into a MongoDB collection?

Working with MongoDB Easy
A. db.collection.addOne()
B. db.collection.put()
C. db.collection.insertOne()
D. db.collection.create()

13 What does JSON stand for?

JSON databases Easy
A. Just Some Object Notation
B. JavaScript Object Notation
C. Java Standard Object Notation
D. Java Serialized Object Network

14 Which two basic structures make up JSON data?

JSON databases Easy
A. Key-value pairs and Arrays
B. Tuples and Relations
C. Graphs and Nodes
D. Tables and Columns

15 In a JSON document, how is an array of items enclosed?

JSON representation of part of the dataset Easy
A. Curly braces { }
B. Parentheses ( )
C. Angle brackets < >
D. Square brackets [ ]

16 Which of the following is the correct syntax for a key-value pair in JSON?

JSON representation of part of the dataset Easy
A. <name>Alice</name>
B. "name" : "Alice"
C. "name" = "Alice"
D. name -> "Alice"

17 What is the primary reason for creating an index in MongoDB?

Index creation & performance comparison using EXPLAIN Easy
A. To encrypt the data
B. To convert data to SQL format
C. To improve query execution speed
D. To compress the storage size

18 Which method is appended to a MongoDB query to return statistics about the query's execution plan?

Index creation & performance comparison using EXPLAIN Easy
A. .explain()
B. .plan()
C. .analyze()
D. .profile()

19 Vector databases are primarily designed to store and search which type of data?

Vector Databases Easy
A. High-dimensional vectors (embeddings)
B. Tabular financial data
C. Key-value pairs only
D. Relational schemas

20 Which modern technology relies heavily on vector databases to perform similarity searches?

Vector Databases Easy
A. Traditional Web Hosting
B. Blockchain
C. Operating System Kernels
D. Generative AI and Machine Learning

21 Which of the following best describes how MongoDB natively handles horizontal scaling and high availability?

Introduction of MongoDB Medium
A. It uses replica sets for high availability and sharding for horizontal scaling.
B. It uses sharding for high availability and replica sets for horizontal scaling.
C. It relies on vertical scaling by adding more RAM and CPU to a single master node.
D. It uses consistent hashing across peer-to-peer nodes without designated primaries.

22 An application requires strict ACID properties across multiple documents and collections. How does modern MongoDB (version 4.0 and later) address this requirement?

Introduction of MongoDB Medium
A. It uses external transaction managers like Apache Kafka to ensure ACID properties.
B. It does not support ACID properties; it only provides eventual consistency.
C. It enforces ACID only within a single document using the $isolated operator.
D. It supports multi-document transactions using a two-phase commit protocol internally.

23 In Amazon DynamoDB, when selecting a partition key for a high-traffic table, which strategy is most effective to avoid "hot partitions"?

DynamoDB Medium
A. Choosing a partition key with a small number of distinct values.
B. Choosing a boolean attribute as the partition key.
C. Using a sequential auto-incrementing integer as the partition key.
D. Choosing a partition key with high cardinality to ensure uniform request distribution.

24 How does DynamoDB allow efficient querying of attributes that are not part of the primary table's partition or sort key?

DynamoDB Medium
A. By writing complex SQL JOIN statements across partitions.
B. By using Global Secondary Indexes (GSI) and Local Secondary Indexes (LSI).
C. By executing full table scans in the background.
D. By automatically creating B-tree indexes on all attributes.

25 When migrating a sporadically used application to a serverless cloud database like Amazon Aurora Serverless, what is the primary architectural advantage?

Serverless cloud database Medium
A. The compute capacity scales automatically based on load and can pause during inactivity, reducing costs.
B. It completely eliminates the need for database backups and disaster recovery.
C. It automatically translates NoSQL queries into standard SQL.
D. It provides dedicated hardware for predictable, constant latency regardless of cost.

26 Which of the following best differentiates a serverless database pricing model from a traditional provisioned cloud database pricing model?

Serverless cloud database Medium
A. Serverless databases charge based on reserved instance types and uptime.
B. Serverless databases charge primarily based on the volume of operations and storage consumed.
C. Serverless databases are entirely free because they run on shared infrastructure.
D. Serverless databases require upfront licensing fees.

27 In MongoDB, how can a database administrator enforce specific data types and required fields despite the database being fundamentally schema-less?

Structure of MongoDB Medium
A. By using JSON Schema validation rules applied at the collection level.
B. By configuring the strict_schema parameter in the mongod.conf file.
C. By writing triggers that execute before every INSERT statement.
D. By defining primary and foreign keys in the collection settings.

28 Which of the following correctly maps the structural components of a traditional RDBMS to MongoDB?

Structure of MongoDB Medium
A. Table Field, Row Document, Column BSON
B. Table Collection, Row Document, Column Field
C. Table Document, Row Collection, Column Field
D. Database Collection, Table Field, Row Document

29 An application handles a dynamic product catalog where each category of items has completely different attributes. Why might a NoSQL document database be preferred over a traditional SQL database in this scenario?

SQL vs NoSql Medium
A. SQL databases cannot store text strings longer than 255 characters.
B. NoSQL databases offer flexible schemas, preventing sparse tables filled with NULL values.
C. SQL databases lack support for indexing entirely.
D. NoSQL databases support complex JOIN operations natively, which simplifies catalog querying.

30 In which of the following scenarios is a traditional SQL database generally a better choice than a NoSQL database?

SQL vs NoSql Medium
A. A mobile app requiring offline synchronization of JSON documents.
B. A financial ledger system requiring strict referential integrity and complex ad-hoc multi-table reporting.
C. An IoT application capturing unstructured sensor data logs.
D. A real-time bidding platform requiring microsecond writes at a massive scale.

31 Which of the following MongoDB queries correctly finds all documents in the employees collection where age is greater than 30 and status is "Active"?

Working with MongoDB Medium
A. db.employees.find({ age: > 30, status: "Active" })
B. db.employees.query({ $and: [ age > 30, status = "Active" ] })
C. db.employees.find({ age: { $gt: 30 }, status: "Active" })
D. db.employees.search({ age: { $greater: 30 }, status: "Active" })

32 A developer wants to update a document in MongoDB, but if no document matches the query filter, a new document should be created. Which option must be used with the updateOne() method?

Working with MongoDB Medium
A. { createIfMissing: true }
B. { upsert: true }
C. { insertNode: true }
D. { merge: true }

33 Why do JSON databases like MongoDB use internal binary representations (like BSON) instead of storing data purely as plain text JSON?

JSON databases Medium
A. Because BSON allows for complex joins using SQL syntax.
B. Because BSON compresses data using advanced lossy algorithms.
C. Because JSON strings cannot be transmitted over HTTP.
D. Because BSON provides faster traversability, efficient encoding, and supports additional data types like Date and BinData.

34 When querying a JSON database, how are fields within nested objects typically accessed?

JSON databases Medium
A. Using dot notation, e.g., "parent.child"
B. By flattening the document before querying.
C. By writing a recursive function inside the query.
D. Using bracket notation exclusively, e.g., parent['child']

35 Consider a scenario where a user has multiple phone numbers. What is the most efficient and standard JSON representation for this one-to-many relationship within a single document?

JSON representation of part of the dataset Medium
A. "phones": { "1": "1234567890", "2": "0987654321" }
B. "phone1": "1234567890", "phone2": "0987654321"
C. "phones": "1234567890, 0987654321"
D. "phones": ["1234567890", "0987654321"]

36 When deciding whether to embed a dataset or reference it in a JSON document, which of the following is a primary drawback of the embedding approach?

JSON representation of part of the dataset Medium
A. It increases the number of database queries required to fetch the data.
B. It makes it impossible to query the embedded fields.
C. It can lead to duplicated data and unbound document growth exceeding the database's document size limit.
D. It forces the database to convert the data into a relational table format.

37 When analyzing a query using MongoDB's explain("executionStats"), which combination of metrics strongly suggests that an index is NOT being utilized effectively?

Index creation & performance comparison using EXPLAIN Medium
A. totalDocsExamined is much larger than nReturned
B. executionTimeMillis is close to zero
C. totalDocsExamined is equal to nReturned
D. totalKeysExamined is equal to nReturned

38 A developer creates a compound index on a collection: { department: 1, salary: -1 }. Which of the following queries will be optimally supported by this index?

Index creation & performance comparison using EXPLAIN Medium
A. Sorting by salary descending, without filtering by department.
B. Filtering by salary and sorting by department ascending.
C. Sorting by department descending and salary ascending.
D. Filtering by department and sorting by salary descending.

39 In Vector Databases used for AI applications, what is the mathematical purpose of calculating Cosine Similarity between two high-dimensional vectors?

Vector Databases Medium
A. To measure the orientation/angle difference between two vectors to determine their semantic similarity.
B. To compress the vector data into a lower-dimensional space.
C. To encrypt the vector embeddings before storage.
D. To exact-match strings based on ASCII values.

40 Why do standard relational databases struggle with fast similarity searches on Large Language Model (LLM) embeddings (vectors in ) compared to purpose-built Vector Databases?

Vector Databases Medium
A. LLM embeddings are strictly formatted as XML, which RDBMS cannot parse.
B. Relational databases cannot store floating-point numbers.
C. Vector Databases use B-Tree indexing which RDBMS lack.
D. RDBMS lack specialized Approximate Nearest Neighbor (ANN) algorithms like HNSW required for high-dimensional searches.

41 In a distributed database architecture evaluated under the PACELC theorem, a system is configured to prioritize Availability over Consistency during a partition, but prioritizes Consistency over Latency during normal operations. Which of the following database configurations most accurately reflects this behavior?

SQL vs NoSql Hard
A. A NoSQL database like Cassandra configured with replication factor 3, read quorum 1, and write quorum 3.
B. A NoSQL database like DynamoDB configured with eventual consistency for reads, but strongly consistent conditional writes.
C. A standard relational SQL database with synchronous master-slave replication.
D. A NoSQL database prioritizing AP during partitions and returning stale data, while using strongly consistent reads by default when the network is healthy.

42 A developer migrates a highly normalized SQL schema containing an Order table and an OrderItems table to a NoSQL document database. They decide to embed OrderItems as an array inside the Order document. Under which condition does this NoSQL data model become a critical anti-pattern?

SQL vs NoSql Hard
A. When the application frequently requires querying the sum of all OrderItems prices for a specific order.
B. When the application needs to retrieve the Order details without the OrderItems.
C. When the OrderItems array grows unboundedly, exceeding the hard document size limit (e.g., 16MB in MongoDB), leading to write failures.
D. When there are frequent concurrent reads to the same Order document.

43 A MongoDB replica set consists of a Primary, two Secondary nodes, and an Arbiter. A client executes a write operation with writeConcern: { w: "majority" }. If one Secondary node goes down, what will be the outcome of the write operation?

Introduction of MongoDB Hard
A. The write will succeed because the Arbiter acts as an acknowledging node for the write concern.
B. The write will fail immediately because a majority of data-bearing nodes (3 nodes) cannot acknowledge it.
C. The write will succeed because the Primary and the remaining Secondary form a majority of the 3 data-bearing nodes.
D. The write will block indefinitely or until a timeout occurs, because 'majority' requires acknowledgment from 2 data-bearing nodes, but only 1 Secondary is available.

44 MongoDB uses BSON to store documents. Which of the following best describes the structural advantage of BSON over standard JSON when querying deeply nested numeric data?

Structure of MongoDB Hard
A. BSON natively supports indexing on string representations of numbers, making text searches faster.
B. BSON automatically compresses redundant JSON keys into a shared dictionary, reducing disk I/O significantly during collection scans.
C. BSON stores length prefixes for elements and specific numeric types (e.g., 32-bit integer, 64-bit float), allowing the query engine to skip unneeded fields without parsing the entire document.
D. BSON translates all numbers into IEEE 754 strings internally, ensuring no precision loss during cross-platform schema validation.

45 When storing a 10MB file in MongoDB using GridFS with a default chunk size of 255KB, how is the file structurally represented and maintained transactionally during upload?

Structure of MongoDB Hard
A. It is split into documents in fs.chunks. GridFS does not inherently guarantee atomicity for the whole file upload; if the upload is interrupted, orphaned chunks may remain.
B. It is stored as a binary BLOB in the fs.files collection, with GridFS mapping byte-ranges in memory to bypass the 16MB limit.
C. It is split into exactly 40 documents in the fs.chunks collection and 1 document in fs.files. The operation requires a multi-document transaction to ensure atomicity.
D. It is stored in a single BSON document in the fs.files collection, chunked internally in a multi-key array.

46 An application writes objects of 3.5 KB to a DynamoDB table at a rate of 150 items per second using strongly consistent reads. How many Write Capacity Units (WCUs) must be provisioned to sustain this workload without throttling, assuming no adaptive capacity burst is available?

DynamoDB Hard
A. 525 WCUs
B. 150 WCUs
C. 600 WCUs
D. 300 WCUs

47 A developer needs to query a DynamoDB table by a different partition key than the base table, and requires strong consistency for these queries. Which secondary index type should they choose and why?

DynamoDB Hard
A. Neither index supports this requirement natively; strong consistency with a different partition key is impossible in DynamoDB without application-level workarounds.
B. Global Secondary Index (GSI), because it can project all base table attributes, effectively synchronizing strong reads.
C. Global Secondary Index (GSI), because it allows a different partition key and supports strong consistency.
D. Local Secondary Index (LSI), because it supports strong consistency, even though it shares the same partition key as the base table.

48 In a Serverless Cloud Database architecture utilizing stateless compute functions (like AWS Lambda) that connect directly to a traditional relational database (without a proxy), which of the following failure modes is most likely to occur under a sudden traffic spike?

Serverless cloud database Hard
A. Database engine deadlock caused by distributed transactions across multiple ephemeral compute instances.
B. Connection exhaustion at the database layer due to the compute instances failing to reuse TCP connections across concurrent function invocations.
C. Storage I/O throttling because serverless databases scale compute independently of storage.
D. Compute layer OOM (Out of Memory) due to caching large query result sets.

49 When contrasting Aurora Serverless v2 with DynamoDB On-Demand pricing and scaling, which statement accurately reflects a key architectural difference in how they handle capacity scaling?

Serverless cloud database Hard
A. Aurora Serverless pauses compute entirely (scaling to zero) instantly when idle, whereas DynamoDB On-Demand always maintains a warm connection pool.
B. DynamoDB scales read/write capacity units instantly on a per-request basis, whereas Aurora Serverless scales compute capacity (ACUs) up and down based on resource utilization metrics over time.
C. Both scale instantly per request, but Aurora Serverless billing is calculated per gigabyte scanned, whereas DynamoDB is billed per compute hour.
D. DynamoDB On-Demand limits scaling based on the number of underlying table partitions, whereas Aurora Serverless can scale table partitions infinitely without compute impact.

50 Consider an Aggregation Pipeline in MongoDB: [ { $unwind: "$tags" }, { $match: { tags: "database" } }, { $sort: { score: -1 } } ]. To optimize this pipeline for a collection with millions of documents, what structural change is strictly necessary to utilize indexes effectively?

Working with MongoDB Hard
A. The pipeline is already optimal because $unwind operates in memory before filtering.
B. Replace $unwind with $lookup to avoid index fragmentation on array fields.
C. Move $sort before $match so the index on score can be used to order documents prior to unwinding.
D. Move $match to be the first stage in the pipeline to filter documents using an index on tags before unwinding arrays.

51 MongoDB provides multi-document ACID transactions. If a transaction spans multiple shards, how does the MongoDB routing service (mongos) ensure atomicity?

Working with MongoDB Hard
A. By writing a unified oplog entry to the config server, which is then broadcasted synchronously to all participating shards.
B. By falling back to eventual consistency across shards, ensuring atomicity only within a single replica set.
C. By locking all collections on all shards globally until the transaction commits.
D. By utilizing a two-phase commit (2PC) protocol managed by the transaction coordinator on the primary node of the shard that received the first write.

52 JSON lacks a native Date datatype, often storing dates as ISO 8601 strings. In a JSON database, what is the primary consequence of querying a date range directly on these string fields without casting?

JSON databases Hard
A. The query will work efficiently using lexicographical sorting, but will return incorrect results if the strings include varying timezone offsets (e.g., +00:00 vs -07:00) instead of being normalized to UTC.
B. The database must perform a full collection scan because strings cannot be indexed for range queries.
C. The query evaluates the strings based on their byte-length rather than chronological order.
D. The query will fail due to strict type enforcement in JSON schema parsers.

53 When storing highly polymorphic JSON documents in a database utilizing Schema-on-Read, a user writes a query filtering on an attribute that exists in only 1% of the documents. What is the most significant performance limitation if no sparse index is present?

JSON databases Hard
A. The query optimizer will ignore the filter condition and return all documents, leaving filtering to the application layer.
B. The database automatically creates an ephemeral index in memory, delaying the first query execution but optimizing subsequent ones.
C. The database will throw a schema violation error for the 99% of documents missing the field.
D. The query engine must retrieve and parse the JSON structure of every document to check for the field's existence, resulting in high CPU and I/O overhead.

54 To represent a hierarchical 'Employee-Manager' organizational chart in a JSON dataset, a developer implements the Materialized Paths pattern. Which of the following is an accurate representation of a node in this design?

JSON representation of part of the dataset Hard
A. { "_id": "Dev1", "manager": "EngLead", "subordinates": [] }
B. { "_id": "Dev1", "left": 14, "right": 15 }
C. { "_id": "Dev1", "ancestors": ["EngLead", "CTO", "CEO"] }
D. { "_id": "Dev1", "path": ",CEO,CTO,EngLead,", "level": 4 }

55 When modeling a Many-to-Many (M:N) relationship between Students and Courses strictly using JSON document structures, embedding Students within Courses leads to data duplication. If we instead use an 'Array of References' (storing course IDs in the student document), what is the primary query complexity introduced?

JSON representation of part of the dataset Hard
A. To retrieve a course and all its enrolled students, the application must execute an application-level join, making two separate database queries or using a complex $lookup pipeline.
B. The references will automatically enforce referential integrity, locking the Courses collection during student updates.
C. It completely prevents the use of secondary indexes on course IDs.
D. The maximum array size limit will be reached rapidly, as a course usually has thousands of students.

56 A MongoDB collection has a compound index { "status": 1, "created_at": -1 }. Which of the following query/sort combinations will result in an in-memory sort, bypassing the sort optimization of the index?

Index creation & performance comparison using EXPLAIN Hard
A. db.orders.find({ status: "A" }).sort({ created_at: -1 })
B. db.orders.find({ status: "A" }).sort({ created_at: 1 })
C. db.orders.find().sort({ status: 1, created_at: -1 })
D. db.orders.find().sort({ status: -1, created_at: 1 })

57 A MongoDB collection has a compound index { "category": 1, "price": -1 }. Which of the following operations will trigger an in-memory sort (represented as SORT stage in EXPLAIN) rather than using the index for sorting?

Index creation & performance comparison using EXPLAIN Hard
A. db.products.find().sort({ category: 1, price: 1 })
B. db.products.find().sort({ category: -1, price: 1 })
C. db.products.find().sort({ category: 1, price: -1 })
D. db.products.find({ category: "electronics" }).sort({ price: 1 })

58 When analyzing the output of an explain("executionStats") command in MongoDB, you observe that totalKeysExamined is 10,000, but totalDocsExamined is 0. What is the most accurate conclusion?

Index creation & performance comparison using EXPLAIN Hard
A. The collection is empty, but the index tree still contains 10,000 orphaned leaf nodes.
B. The query was completely covered by the index, meaning all queried and projected fields were satisfied by the index keys alone.
C. The query used an index, but the index was highly unselective, resulting in poor performance.
D. The query failed to find any documents matching the criteria, resulting in a null set.

59 In Vector Databases, indexing high-dimensional data for exact k-Nearest Neighbors (k-NN) has time complexity. To improve latency, systems use Approximate Nearest Neighbor (ANN) algorithms. Which of the following describes the HNSW (Hierarchical Navigable Small World) index structure used to achieve sub-linear time?

Vector Databases Hard
A. It uses clustering (like K-Means) to divide the vector space into Voronoi cells, assigning vectors to the nearest centroid.
B. It quantizes vectors into 8-bit integers, mathematically compressing the matrix multiplication space to fit into GPU L1 cache.
C. It constructs a multi-layered graph where upper layers have fewer connections for long-distance traversals, and lower layers are dense for localized greedy search.
D. It projects high-dimensional vectors onto random lower-dimensional hyperplanes to generate binary hash codes for Hamming distance comparison.

60 When computing vector similarity, Cosine Similarity calculates the angle between two vectors, while Euclidean Distance () measures geometric straight-line distance. If all vectors in a database are strictly normalized (magnitude of 1), what is the mathematical relationship between Euclidean distance squared () and Cosine Similarity ()?

Vector Databases Hard
A.
B.
C. There is no deterministic relationship; they must be computed independently even if normalized.
D.