NoSQL Databases (e.g., MongoDB, Cassandra) MCQs

By: Prof. Dr. Fazal Rehman Shamil | Last updated: August 7, 2024

General NoSQL Databases
What is a primary characteristic of NoSQL databases compared to traditional relational databases?
a) They support complex SQL queries
b) They use a fixed schema
c) They are designed for scalability and flexibility
d) They store data in tables with rows and columns
Answer: c) They are designed for scalability and flexibility

Which of the following is a type of NoSQL database?
a) MySQL
b) PostgreSQL
c) MongoDB
d) Oracle Database
Answer: c) MongoDB

What does ACID stand for in the context of database transactions?
a) Atomic, Consistent, Isolated, Durable
b) Automated, Consistent, Isolated, Distributed
c) Atomic, Continuous, Isolated, Distributed
d) Automated, Consistent, Isolated, Durable
Answer: a) Atomic, Consistent, Isolated, Durable

Which type of NoSQL database is optimized for storing and retrieving key-value pairs?
a) Document-oriented
b) Column-family
c) Graph-based
d) Key-value
Answer: d) Key-value

What is a common use case for a document-oriented NoSQL database like MongoDB?
a) Storing complex relationships between entities
b) Storing and retrieving hierarchical data structures
c) Storing data in tables with fixed schemas
d) Performing complex joins across multiple tables
Answer: b) Storing and retrieving hierarchical data structures

MongoDB
What is BSON in the context of MongoDB?
a) Binary Structure Object Notation
b) Binary Serialized Object Notation
c) Basic Structure Object Notation
d) Binary Serialized Object Namespace
Answer: b) Binary Serialized Object Notation

Which statement about MongoDB’s schema is true?
a) MongoDB enforces a fixed schema for all collections
b) MongoDB allows flexible schemas for collections
c) MongoDB requires SQL queries to retrieve data
d) MongoDB uses a traditional relational database schema
Answer: b) MongoDB allows flexible schemas for collections

How do you perform aggregation operations in MongoDB?
a) Using the JOIN keyword
b) Using the MERGE keyword
c) Using the AGGREGATE framework
d) Using the GROUP BY clause
Answer: c) Using the AGGREGATE framework

What is a sharding key in MongoDB?
a) A unique identifier for each document
b) A field used to distribute data across multiple shards
c) A field used for indexing purposes
d) A primary key in a collection
Answer: b) A field used to distribute data across multiple shards

How do you create an index on a field in a MongoDB collection?
a) createIndex()
b) addIndex()
c) index.create()
d) ensureIndex()
Answer: a) createIndex()

Cassandra
What is the primary data model used in Cassandra?
a) Document-oriented
b) Key-value
c) Column-family
d) Graph-based
Answer: c) Column-family

Which of the following is a characteristic of Cassandra’s architecture?
a) Strong consistency model
b) Single point of failure
c) Centralized data storage
d) Master-slave replication
Answer: b) Single point of failure

How does Cassandra ensure fault tolerance and high availability?
a) By using a master-slave architecture
b) By replicating data across multiple nodes
c) By enforcing strict ACID transactions
d) By storing data in a single node
Answer: b) By replicating data across multiple nodes

Which query language is used to interact with Cassandra?
a) SQL
b) CQL (Cassandra Query Language)
c) Cypher
d) NoQL
Answer: b) CQL (Cassandra Query Language)

What is a key advantage of using Cassandra for distributed databases?
a) High write latency
b) Linear scalability
c) Limited data replication
d) Structured schema requirement
Answer: b) Linear scalability

NoSQL Databases Comparison
What is a key difference between MongoDB and Cassandra?
a) MongoDB uses a document-oriented data model, while Cassandra uses a column-family data model
b) Cassandra supports complex SQL queries, while MongoDB does not
c) MongoDB does not support replication, while Cassandra does
d) Cassandra enforces a fixed schema, while MongoDB allows flexible schemas
Answer: a) MongoDB uses a document-oriented data model, while Cassandra uses a column-family data model

Which NoSQL database is suitable for applications requiring high availability and linear scalability?
a) MongoDB
b) Cassandra
c) Redis
d) Neo4j
Answer: b) Cassandra

What is a common disadvantage of using NoSQL databases?
a) Limited scalability
b) Fixed schema
c) Complex querying capabilities
d) Eventual consistency
Answer: d) Eventual consistency

How do NoSQL databases typically handle transactions compared to traditional relational databases?
a) NoSQL databases support full ACID transactions
b) NoSQL databases have limited support for ACID transactions
c) NoSQL databases use a centralized architecture
d) NoSQL databases enforce strict schema constraints
Answer: b) NoSQL databases have limited support for ACID transactions

Which NoSQL database is known for its in-memory data storage and high-speed data access?
a) MongoDB
b) Cassandra
c) Redis
d) HBase
Answer: c) Redis