Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Apache Cassandra

Urvil
December 31, 2023

Apache Cassandra

Urvil

December 31, 2023
Tweet

More Decks by Urvil

Other Decks in Technology

Transcript

  1. Features • NoSQL • Lightweight • Open-source • Non-relational •

    Fault Tolerant • Horizontally scalable • Highly available • Configurable Consistency
  2. Data is Replicated A replication factor of three ensures that

    there are three nodes (replicas) covering that particular token range.
  3. Is Cassandra AP or CP? Cassandra is configurable consistent. In

    any moment of the time for any particular query you can set the Consistency Level you require to have. Cassandra Consistency Levels: • ANY • ONE • TWO • THREE • QUORUM • ALL
  4. Keyspaces CREATE KEYSPACE financial_data WITH replication = { 'class': 'SimpleStrategy',

    'replication_factor': 2 }; replication factor keyspace replication strategy
  5. Creating a Table in CQL CREATE TABLE financial_data.financial_transactions ( timestamp

    TIMESTAMP, from_bank TEXT, from_account TEXT, to_bank TEXT, to_account TEXT, amount_received DECIMAL, receiving_currency TEXT, amount_paid DECIMAL, payment_currency TEXT, payment_format TEXT, is_laundering BOOLEAN, PRIMARY KEY ((from_bank, to_bank), timestamp, payment_currency, is_laundering) ); keyspace table primary key partition key clustering columns
  6. Primary Key An identifier for a row. Consists of at

    least one Partition Key and zero or more Clustering columns. MUST ENSURE UNIQUENESS. MAY DEFINE SORTING. PRIMARY KEY ((from_bank, to_bank), timestamp, payment_currency, is_laundering) Primary key Partition key Clustering columns
  7. Partition Key An identifier for a partition. Consists of at

    least one column, may have more if needed PARTITION ROWS. PRIMARY KEY ((from_bank, to_bank), timestamp, payment_currency, is_laundering) Partition key
  8. Clustering Column(s) Used to ensure uniqueness and sorting order. Optional.

    PRIMARY KEY ((from_bank, to_bank), timestamp, payment_currency, is_laundering) Clustering columns