Home > OS >  Is there a way to query by column family in Cassandra NoSQL?
Is there a way to query by column family in Cassandra NoSQL?

Time:05-26

Table Creation Attempt:

CREATE TABLE users_v1 (
guid uuid PRIMARY KEY,
notice text,
first_name text,
last_name text,
obsidian text,
starlight text,
bids text,
apps text,
FAMILY f1 (first_name, last_name),
FAMILY f2 (obsidian, starlight),
FAMILY f3 (bids, apps)
);

I've tried to make queries based on f*, but I can't seem to get just (first_name, last_name) returned or written. I'm sure I'm missing a major concept here.

  1. The main idea is that any user object has 3 families of columns that can be extended as time goes on.
  2. The other idea is that any query whether select or insert should be able to call just the family e.g. f2 and only update the columns in that family.

Can this be done with families? Or is there another way to leverage wide rows, dynamic columns or some feature of NoSQL that I'm missing?

I'm new to databases, so 5 year old explanations are much appreciated. I've thought about using table joins in SQL but don't think it will scale reliably considering the object itself will extended.

CodePudding user response:

Modern Cassandra doesn't operate in terms of the column families - it was original design, finally deprecated in Cassandra 4.0.

If you want to update only specific columns - just specify them (plus primary key). Cassandra won't update the rest with null or something like - by default Cassandra operate by individual cells (column values) not the full rows. Same for selects - if you want to get only specific columns, specify them in the SELECT statement.

I would recommend you to get 3rd edition of the "Cassandra: The definitive guide" - it may still available from the DataStax's site.

  • Related