programming
beginner
10 sample questions
Nosql MCQ Practice Test
an approach to database design that enables the storage and querying of data outside the traditional structures found in relational databases.
Q1. For a social platform storing each user's friends with friendship timestamps, requiring high write throughput and efficient retrieval of a user's friends ordered by when they became friends, which NoSQL model fits best?
-
A. A graph database using a property graph model
-
B. A document database with nested friend objects, sorted by timestamp
-
C. A key-value store with user IDs as keys and JSON arrays of friends as values
-
D. A wide-column store where each user is a row and columns represent friends with timestamps as qualifiers ✓
Explanation: Wide-column stores such as Cassandra are built for massive write throughput and denormalized data; storing friends as columns clustered by timestamp makes 'friends ordered by friendship time' a single efficient row read. Documents also nest friends but degrade with very large lists; key-value stores lack native ordering; graph databases suit traversal analytics rather than time-ordered reads at scale.
Q2. You are designing a NoSQL database for a social media platform. Each user can have multiple friends, and each friend relationship needs to be easily retrievable. Considering scalability and efficient retrieval of friend lists, which NoSQL data model would be MOST suitable for storing this user-friend relationship data?
-
A. Graph Database ✓
-
B. Document Database
-
C. Key-Value Store
-
D. Wide-Column Store
Explanation: A graph database is ideal for representing relationships. Nodes represent users, and edges represent friendships. Retrieving a user's friend list involves a simple traversal of the graph, making it efficient for this type of data. While other models could work, they would likely be less efficient for querying and managing many-to-many relationships at scale.
Q3. In a distributed NoSQL database, what is the primary purpose of a Raft-based leader election algorithm?
-
A. To ensure data consistency across all nodes
-
B. To optimize query performance by load balancing
-
C. To determine the primary replica for each shard
-
D. To handle network partitions and leader failures ✓
Explanation: Raft-based leader election algorithms are designed to ensure the continued operation of a distributed NoSQL database in the presence of network partitions or leader failures. This is achieved by electing a new leader node to take over the responsibilities of the failed node, thereby maintaining the availability of the database.
Q4. According to the CAP theorem, a distributed data store that faces a network partition must sacrifice either ____.
-
A. consistency or availability ✓
-
B. security or speed
-
C. storage capacity or bandwidth
-
D. latency or durability
Explanation: Brewer's CAP theorem: during a partition (P), a system can preserve consistency (C) or availability (A), not both. Linearizability cannot be guaranteed across a partition.
Q5. In a distributed NoSQL database with a sharded architecture, what is the primary advantage of using a consistent hashing algorithm for shard key distribution?
-
A. Improved data locality and reduced network latency ✓
-
B. Increased availability and fault tolerance through automatic shard rebalancing
-
C. Optimized write performance by minimizing the number of nodes involved in each write operation
-
D. Enhanced query performance through more efficient data retrieval
Explanation: Consistent hashing algorithms ensure that each shard is assigned a range of keys in a way that minimizes the number of key-range changes when a new node is added or removed from the cluster. This leads to improved data locality and reduced network latency, as data is more likely to be stored on the same node where it is being accessed.
Q6. In a distributed NoSQL database, what is the 'split brain' condition?
-
A. The cluster partitions into sub-groups that cannot communicate, and each may accept writes believing it is the only active group ✓
-
B. All nodes synchronize their state automatically to stay consistent
-
C. Replication latency is reduced across data centers
-
D. The database stops accepting all writes until every node responds
Explanation: Split brain occurs when a network partition divides the cluster into isolated sub-groups that cannot communicate; each side may believe it is the primary and accept writes, causing divergent data that must be reconciled. Distributed databases use quorums and leader-election mechanisms to prevent it.
Q7. In a distributed NoSQL database like Apache Cassandra, what is the primary function of a "Token Ring" in data distribution?
-
A. To ensure data consistency across all nodes in the cluster.
-
B. To enable efficient data replication and redundancy.
-
C. To determine the ownership of data partitions across the cluster. ✓
-
D. To optimize query routing and caching.
Explanation: In Apache Cassandra, the Token Ring is a fundamental concept for data partitioning and distribution. Each node in the cluster is assigned a range of tokens, and the token ring determines which node is responsible for storing a particular piece of data based on the partition key's hash value. This ensures that data is evenly distributed across the cluster and facilitates efficient data retrieval. The coordinator node is selected based on this token ring, but the primary function is data distribution.
Q8. In a distributed NoSQL database, what is the primary goal of the concept of “sharding”?
-
A. To ensure data consistency across all nodes in the cluster
-
B. To divide the data into smaller chunks and store them across multiple nodes ✓
-
C. To implement a master-slave replication strategy
-
D. To optimize query performance by caching frequently accessed data
Explanation: Sharding is a technique used in distributed databases to split large datasets into smaller, more manageable pieces called shards. Each shard is then stored on a separate node in the cluster, allowing for horizontal scaling and improved performance.
Q9. In a distributed NoSQL database, what is the primary challenge posed by a 'split brain' scenario?
-
A. To achieve high availability by maintaining multiple active nodes
-
B. To prevent network partitions from occurring in a cluster
-
C. To ensure data consistency across all nodes in a cluster
-
D. To detect and resolve conflicts between concurrent writes ✓
Explanation: A split-brain scenario occurs when a distributed NoSQL database cluster is partitioned, and different nodes believe they are the primary node. The primary challenge is that concurrent writes to different partitions can lead to data inconsistencies. The goal of addressing split-brain scenarios is to detect and resolve these conflicts, ensuring data consistency across the cluster. This is typically achieved through mechanisms such as conflict resolution strategies, eventual consistency models, or manual intervention.
Q10. In a Cassandra cluster, what is the purpose of the "snitch" configuration option?
-
A. To enable or disable the use of the gossip protocol
-
B. To specify the node to use as the coordinator for a particular query
-
C. To determine the topology of the cluster and how nodes communicate with each other ✓
-
D. To set the replication factor for a given keyspace
Explanation: The snitch configuration option in Cassandra is used to determine the topology of the cluster and how nodes communicate with each other. This is important for routing queries to the correct nodes and ensuring that data is properly replicated across the cluster.
That was just a sample. Sign up to unlock the full question bank with timed tests and certificates.
Sign Up Free