Cassandra Quiz - MCQ Questions and Answers

Introduction

Welcome to this quiz on Apache Cassandra, a powerful NoSQL database designed for handling large amounts of data across many servers without any single point of failure. This quiz is created to help you test your understanding of Cassandra, whether you're just starting to learn about it or want to review key concepts.

The quiz consists of multiple-choice questions covering various aspects of Cassandra, including its architecture, data model, query language, and features like replication and consistency. Each question comes with a clear explanation to help you understand the correct answers.

Take your time with each question, and don't worry if you get some wrong. The goal is to learn and solidify your knowledge. Good luck!

1. What type of database is Cassandra?

a) Relational Database
b) Document-based NoSQL Database
c) Columnar NoSQL Database
d) Graph Database

Answer:

c) Columnar NoSQL Database

Explanation:

Cassandra is a column-oriented NoSQL database designed to manage large volumes of structured data across many servers.

2. Which language is used to query Cassandra?

a) SQL
b) NoSQL
c) CQL
d) DQL

Answer:

c) CQL

Explanation:

Cassandra Query Language (CQL) is a query language for the Cassandra database.

3. Which of the following best describes the architecture of Cassandra?

a) Master-Slave
b) Master-Master
c) Peer-to-Peer
d) Client-Server

Answer:

c) Peer-to-Peer

Explanation:

Cassandra follows a peer-to-peer architecture where all nodes in the cluster are treated equally, avoiding single points of failure.

4. Which company originally developed Cassandra?

a) Google
b) Amazon
c) Facebook
d) Microsoft

Answer:

c) Facebook

Explanation:

Cassandra was originally developed by Facebook to power their Inbox search feature.

5. In Cassandra, what does the term "compaction" refer to?

a) Combining multiple tables
b) Shrinking database size
c) Merging multiple SSTables into one
d) Distributing data uniformly across nodes

Answer:

c) Merging multiple SSTables into one

Explanation:

Compaction in Cassandra refers to the process of reclaiming space by merging SSTables and discarding duplicate data.

6. Which of the following ensures high availability in Cassandra?

a) Master node
b) Sharding
c) Replication
d) Compaction

Answer:

c) Replication

Explanation:

To ensure high availability, data is replicated across multiple nodes in a Cassandra cluster.

7. Which consistency level ensures the fastest write operations in Cassandra?

a) QUORUM
b) ALL
c) ONE
d) TWO

Answer:

c) ONE

Explanation:

With a consistency level of ONE, a write must be written to the commit log and memtable of at least one replica node.

8. Which data structure is used to store data in memory in Cassandra?

a) B-Tree
b) AVL Tree
c) Memtable
d) Log Structured Merge Tree

Answer:

c) Memtable

Explanation:

In Cassandra, data is written and then stored in a memory structure called the memtable.

9. What does SSTable stand for in the context of Cassandra?

a) Super Storage Table
b) Sorted String Table
c) Sequential String Table
d) Sorted String Tree

Answer:

b) Sorted String Table

Explanation:

In Cassandra, SSTable stands for Sorted String Table, which is an immutable data file to which Cassandra writes memtables periodically.

10. In Cassandra, a ‘Keyspace’ is equivalent to what in relational databases?

a) Column
b) Table
c) Database
d) Row

Answer:

c) Database

Explanation:

In Cassandra, a 'Keyspace' is similar to a 'Database' in relational DBMS. It's a namespace to hold a set of tables.

11. What is the primary write destination in Cassandra?

a) Disk
b) Memtable
c) SSTable
d) Commit Log

Answer:

d) Commit Log

Explanation:

In Cassandra, the primary write destination is the commit log. Once the write has been committed to the log, it's then written to the memtable.

12. Which of the following is NOT a component of Cassandra's data model?

a) Column
b) Column family
c) Keyset
d) Super column

Answer:

c) Keyset

Explanation:

Cassandra's data model comprises columns, column families, and super columns. "Keyset" is not a term associated with its data model.

13. What is the default port number on which Cassandra's CQL native transport listens?

a) 9041
b) 9042
c) 8080
d) 7000

Answer:

b) 9042

Explanation:

By default, Cassandra's CQL native transport listens on port 9042. This is the port that client libraries use to connect to the Cassandra cluster.

14. Which CQL query is used to retrieve all columns of all rows from a table named "users"?

a) SELECT ALL FROM users;
b) GET * FROM users;
c) SELECT * FROM users;
d) READ * FROM users;

Answer:

c) SELECT * FROM users;

Explanation:

In Cassandra's CQL, the correct syntax to retrieve all columns of all rows from a table is SELECT * FROM <table_name>;.

15. In CQL, what is the correct data type to store a UUID (Universally Unique Identifier)?

a) UNIQUEID
b) ID
c) STRING
d) UUID

Answer:

d) UUID

Explanation:

In CQL, the UUID data type is used to store universally unique identifiers.

16. Which CQL command is used to modify data in an existing row or rows of a table?

a) MODIFY
b) CHANGE
c) ALTER
d) UPDATE

Answer:

d) UPDATE

Explanation:

The UPDATE command is used in CQL to modify data in an existing row or rows of a table.

17. To delete all rows from a table named "employees" without removing the table itself, which query should be used?

a) DELETE * FROM employees;
b) DROP ALL FROM employees;
c) TRUNCATE employees;
d) REMOVE * FROM employees;

Answer:

c) TRUNCATE employees;

Explanation:

The TRUNCATE command is used to delete all rows from a table while leaving the table structure intact.

18. What is the replication strategy in Cassandra that allows you to specify the number of replicas in each data center?

a) SimpleStrategy
b) NetworkTopologyStrategy
c) LocalStrategy
d) DataCenterStrategy

Answer:

b) NetworkTopologyStrategy

Explanation:

NetworkTopologyStrategy allows you to specify the number of replicas in each data center, providing more control over data replication in multi-datacenter deployments.

19. What happens when a write request is sent to a Cassandra node that is currently down?

a) The write request is lost
b) The write request is queued until the node is back online
c) The write request is sent to another node
d) The write request is dropped

Answer:

c) The write request is sent to another node

Explanation:

In Cassandra, if a node is down, the write request is sent to another available node in the cluster to ensure the write is completed.

20. What is the purpose of the ‘nodetool’ utility in Cassandra?

a) To run CQL queries
b) To manage cluster nodes
c) To configure keyspaces
d) To monitor disk usage

Answer:

b) To manage cluster nodes

Explanation:

The nodetool utility is used in Cassandra to manage and monitor nodes in the cluster, including checking the status of nodes and performing administrative tasks.

21. What is the consistency level in Cassandra that ensures all replicas respond before the operation is considered successful?

a) ONE
b) QUORUM
c) ALL
d) ANY

Answer:

c) ALL

Explanation:

The ALL consistency level ensures that all replicas must respond before the operation is considered successful, providing the highest consistency but at the cost of latency.

22. Which of the following is a valid primary key definition in a CQL table?

a) PRIMARY KEY (column1)
b) PRIMARY KEY (column1, column2)
c) PRIMARY KEY ((column1, column2), column3)
d) All of the above

Answer:

d) All of the above

Explanation:

All the given options are valid primary key definitions in Cassandra, depending on the desired partitioning and clustering key strategy.

23. In Cassandra, what does the ‘Tombstone’ refer to?

a) A type of index
b) A marker for deleted data
c) A special type of column
d) A way to store data securely

Answer:

b) A marker for deleted data

Explanation:

In Cassandra, a tombstone is a marker used to indicate that a piece of data has been deleted. It helps in eventual consistency by ensuring that the deletion is propagated across all replicas.

24. What is the function of the ‘gossip’ protocol in Cassandra?

a) To query the database
b) To distribute data
c) To allow nodes to communicate and share state information
d) To replicate data between data centers

Answer:

c) To allow nodes to communicate and share state information

Explanation:

The gossip protocol in Cassandra allows nodes to communicate with each other and share state information, ensuring that the cluster remains synchronized and that each node has an updated view of the cluster state.

25. Which of the following is a valid statement for creating a keyspace in Cassandra?

a) CREATE DATABASE keyspace_name WITH replication = {'class':'SimpleStrategy', 'replication_factor':1};
b) CREATE KEYSPACE keyspace_name WITH replication = {'class':'SimpleStrategy', 'replication_factor':3};
c) CREATE SCHEMA keyspace_name WITH replication = {'class':'NetworkTopologyStrategy', 'datacenter1':3, 'datacenter2':2};
d) CREATE TABLESPACE keyspace_name WITH replication = {'class':'SimpleStrategy', 'replication_factor':2};

Answer:

b) CREATE KEYSPACE keyspace_name WITH replication = {'class':'SimpleStrategy', 'replication_factor':3};

Explanation:

The correct CQL statement to create a keyspace in Cassandra is using the CREATE KEYSPACE syntax, along with the replication strategy and factor.

Conclusion

We hope this quiz helped you better understand Apache Cassandra and its key features. By going through these questions, you should now have a clearer understanding of Cassandra's architecture, data model, and operations. Keep practicing and reviewing these concepts to solidify your knowledge. Good luck with your continued learning journey!

Comments