MCQs on Cassandra Query Language (CQL) Basics | Cassandra

Chapter 4 covers the basics of Cassandra Query Language (CQL), the primary language used for interacting with Cassandra databases. This chapter explains how to create keyspaces and tables, perform CRUD operations, and understand the different data types in Cassandra. It also delves into partition keys and clustering columns for efficient data distribution and retrieval.


Introduction to CQL

  1. What does CQL stand for in the context of Cassandra?
    a) Cassandra Query Language
    b) Cassandra Queue Language
    c) Column Query Language
    d) Cassandra Query Loader
  2. Which of the following is true about CQL?
    a) It uses SQL-like syntax but operates on a NoSQL database
    b) It is used for querying relational databases
    c) It uses JSON for data manipulation
    d) It is similar to Python
  3. What is the primary purpose of CQL in Cassandra?
    a) Data visualization
    b) To execute map-reduce jobs
    c) To interact with Cassandra databases
    d) To configure server settings
  4. Which of the following is NOT a valid CQL command?
    a) SELECT
    b) CREATE
    c) DROP
    d) MERGE
  5. In CQL, which statement is used to insert data into a table?
    a) ADD INTO
    b) INSERT INTO
    c) PUT DATA
    d) LOAD INTO

Creating Keyspaces and Tables

  1. What is a keyspace in Cassandra?
    a) A container for data storage
    b) A namespace for tables and data
    c) A database within a relational database system
    d) A type of data compression
  2. Which CQL command is used to create a new keyspace?
    a) CREATE DATABASE
    b) CREATE SCHEMA
    c) CREATE KEYSPACE
    d) CREATE TABLESPACE
  3. What is the default replication strategy used when creating a keyspace in Cassandra?
    a) NetworkTopologyStrategy
    b) SimpleStrategy
    c) RackAwareStrategy
    d) DCLStrategy
  4. To create a table in CQL, which command is used?
    a) CREATE TABLE
    b) NEW TABLE
    c) CREATE DATA
    d) DEFINE TABLE
  5. When defining a table in CQL, which is used to uniquely identify rows?
    a) Primary Key
    b) Unique Key
    c) Cluster Key
    d) Partition Key

CRUD Operations

  1. Which CQL command is used to retrieve data from a table?
    a) SELECT
    b) GET
    c) SHOW
    d) FETCH
  2. What does the CQL command INSERT INTO do?
    a) Updates existing records
    b) Deletes data
    c) Adds new rows to a table
    d) Modifies table structure
  3. Which CQL command is used to modify existing data?
    a) CHANGE
    b) UPDATE
    c) ALTER
    d) MODIFY
  4. In CQL, which command is used to delete data from a table?
    a) REMOVE
    b) DELETE
    c) DROP
    d) CLEAR
  5. The CQL command TRUNCATE is used for:
    a) Deleting all data from a table
    b) Dropping the table
    c) Removing a single record
    d) Updating data

Data Types in Cassandra

  1. Which of the following is a valid CQL data type?
    a) STRING
    b) BOOLEAN
    c) INT
    d) All of the above
  2. What is the data type used to store variable-length strings in CQL?
    a) VARCHAR
    b) TEXT
    c) CHAR
    d) STRING
  3. Which data type is used to store dates and times in CQL?
    a) TIMESTAMP
    b) DATETIME
    c) DATE
    d) TIME
  4. Which data type in CQL is used to store a collection of elements of the same type?
    a) SET
    b) LIST
    c) MAP
    d) TUPLE
  5. What is the CQL data type for storing a unique identifier?
    a) UUID
    b) GUID
    c) ID
    d) UNIQUE

Understanding Partition Keys and Clustering Columns

  1. What is the purpose of the partition key in Cassandra?
    a) To group rows within the same table
    b) To distribute rows across nodes
    c) To enforce uniqueness of data
    d) To define relationships between tables
  2. Which CQL clause is used to define the partition key?
    a) PRIMARY KEY
    b) PARTITION KEY
    c) CLUSTERING
    d) INDEX
  3. In Cassandra, what is a clustering column used for?
    a) Identifying partitions
    b) Sorting rows within a partition
    c) Defining data types
    d) Storing large objects
  4. What is the maximum number of clustering columns allowed in a table in Cassandra?
    a) 1
    b) 2
    c) 5
    d) Unlimited
  5. The order of clustering columns affects:
    a) Data storage in the file system
    b) The query performance for sorting and filtering
    c) Data replication across nodes
    d) The security level

Advanced CQL Concepts

  1. When creating a table, the WITH clause in CQL is used for:
    a) Specifying the primary key
    b) Defining the table’s read/write consistency
    c) Defining table-level settings such as compaction or caching
    d) Adding new columns
  2. Which CQL feature is used for controlling read and write consistency levels?
    a) CONSISTENCY
    b) REPLICATION
    c) CLUSTERING
    d) CAPACITY
  3. What is the purpose of the IF NOT EXISTS clause in CQL?
    a) To check if a record exists before inserting
    b) To conditionally create a keyspace or table
    c) To check table schema compatibility
    d) To automatically drop a table if it exists
  4. The ALLOW FILTERING clause in CQL is used to:
    a) Enable filtering on non-primary key columns
    b) Disable filtering in queries
    c) Restrict access to certain data types
    d) Perform data validation
  5. Which of the following is true about CQL in Cassandra?
    a) CQL can only query single-node databases
    b) CQL queries are similar to SQL but adapted for Cassandra’s NoSQL model
    c) CQL is primarily used for data visualization
    d) CQL only supports key-value pairs

Answers Table

QNoAnswer
1a) Cassandra Query Language
2a) It uses SQL-like syntax but operates on a NoSQL database
3c) To interact with Cassandra databases
4d) MERGE
5b) INSERT INTO
6b) A namespace for tables and data
7c) CREATE KEYSPACE
8b) SimpleStrategy
9a) CREATE TABLE
10a) Primary Key
11a) SELECT
12c) Adds new rows to a table
13b) UPDATE
14b) DELETE
15a) Deleting all data from a table
16d) All of the above
17a) VARCHAR
18a) TIMESTAMP
19b) LIST
20a) UUID
21b) To distribute rows across nodes
22b) PARTITION KEY
23b) Sorting rows within a partition
24d) Unlimited
25b) The query performance for sorting and filtering
26c) Defining table-level settings such as compaction or caching
27a) CONSISTENCY
28b) To conditionally create a keyspace or table
29a) Enable filtering on non-primary key columns
30b) CQL queries are similar to SQL but adapted for Cassandra’s NoSQL model

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top