Cassandra Data Model Essentials: Keyspaces, Tables, and Columns Quiz Quiz

Challenge your understanding of Cassandra's data modeling concepts with questions on keyspaces, tables, column types, and structure. Learn to recognize foundational terms and best practices crucial for effective schema design in distributed databases.

  1. Understanding Keyspaces

    Which statement best describes a keyspace in Cassandra?

    1. A column within a specific table
    2. A logical namespace that defines replication and contains tables
    3. A single row of data within a table
    4. A unique value used to identify a column

    Explanation: A keyspace in Cassandra acts as a logical namespace for grouping tables and defining replication settings. It is not a row within a table, which is a data unit, nor is it a column or a value that identifies columns. Keyspaces are at the highest level in Cassandra's data hierarchy, while the other options refer to lower-level structures.

  2. Defining Tables

    In Cassandra, what is a table primarily used for within a keyspace?

    1. Measuring query execution time
    2. Determining database user permissions
    3. Storing and organizing rows of data
    4. Defining the number of nodes in a cluster

    Explanation: Tables in Cassandra are designed to store and organize rows of related data within a keyspace. The other options refer to cluster configuration (number of nodes), permissions management, or query metrics, none of which describe the purpose of a table.

  3. Primary Keys in Table Design

    What is the main role of a primary key when creating a table in Cassandra?

    1. Granting users write access to the table
    2. Defining the data type of a column
    3. Uniquely identifying each row in the table
    4. Setting the table's replication factor

    Explanation: A primary key ensures each row in a table can be uniquely identified and efficiently retrieved. It does not define column data types, handle user permissions, or manage replication strategies; those are managed in different ways within Cassandra.

  4. Column Types

    Which of the following is a valid data type for a column in Cassandra tables?

    1. text
    2. widget
    3. panel
    4. file

    Explanation: The 'text' data type is used for storing string values in Cassandra columns. 'File', 'widget', and 'panel' are not valid data types in Cassandra and don't correspond to supported storage formats.

  5. Role of Partition Keys

    In Cassandra data modeling, what is the main purpose of the partition key?

    1. Specifying the default column value
    2. Granting read permissions to users
    3. Determining how data is distributed across nodes
    4. Enabling data encryption for a table

    Explanation: Partition keys dictate how rows are distributed across the nodes in the cluster, thereby impacting data locality and performance. They do not set default values, manage user permissions, or handle data encryption; these are managed elsewhere.

  6. Clustering Columns

    What is the main function of clustering columns in a Cassandra table?

    1. Back up the entire keyspace
    2. Configure network topology
    3. Determine the table's partition key
    4. Sorting data within each partition

    Explanation: Clustering columns are used to sort the data within each partition, allowing for efficient range queries. Backing up keyspaces and network configuration are not related to clustering columns, and determining the partition key is defined separately from clustering columns.

  7. Table Constraints

    Which constraint can be enforced on a Cassandra table column?

    1. Foreign key
    2. Check constraint
    3. Unique except primary key
    4. Primary key

    Explanation: Cassandra supports defining a primary key constraint to ensure row uniqueness. However, it does not natively enforce unique, foreign key, or check constraints as found in some other database systems.

  8. Static Columns

    What is the primary characteristic of a static column in a Cassandra table?

    1. Its value is shared among all rows in a partition
    2. It cannot be updated once set
    3. It can only store numeric values
    4. Its name must start with 'static_'

    Explanation: A static column's value is the same for all rows within a given partition, making it useful for partition-level attributes. Static columns are not restricted to numeric values, can be updated, and have no naming requirements like starting with 'static_'.

  9. Case Sensitivity of Names

    How does Cassandra treat keyspace, table, and column names by default?

    1. Names must be exactly 8 characters long
    2. All names must be in uppercase
    3. Names are stored in lowercase unless quoted
    4. Names are always case-sensitive

    Explanation: Unquoted keyspace, table, and column names are converted to lowercase by default. Names are not required to be in uppercase, are not always case-sensitive, and there is no length restriction of exactly 8 characters.

  10. Adding Columns

    Which statement about adding columns to an existing table in Cassandra is correct?

    1. A table can have no more than 50 columns
    2. Removing a column requires rewriting the entire table
    3. All rows must be updated when a new column is added
    4. New columns can be added at any time without affecting existing data

    Explanation: Cassandra allows the addition of new columns whenever necessary, and existing rows are left unaffected—missing values are simply handled as null. There is no hard limit of 50 columns, and the other distractors misrepresent how schema evolution and deletions work in Cassandra.