incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Hillsborough <>
Subject Using CQL to insert a column to a row dynamically
Date Mon, 27 May 2013 14:28:50 GMT
Hi all,

I posted a similar thread on stackoverflow - hope it's not repetitive for
anyone here. Looking for better insight from the community on whether
Cassandra is the right tool for me or not.

I am trying to understand some fundamentals in Cassandra, I was under the
impression that one of the advantages a developer can take in designing a
data model is by dynamically adding columns to a row identified by a key.
That means I can model my data so that if it makes sense, a key can be
something such as a user_id from a relational database, and I can for
example, create arbitrary amounts of columns that relate to that user.

What I'm not understanding is why there is so much emphasis to predefined
columns in CQL examples, particularly in the CREATE TABLE/COLUMNFAMILY


  empID int,

  deptID int,

  first_name varchar,

  last_name varchar,

  PRIMARY KEY (empID, deptID)


Wouldn't this type of model make more sense to just stuff into a relational
database? What if I don't know my column name until runtime and need to
dynamically create it? Do I have to use ALTER TABLE to add a new column to
the row using CQL? The particular app use-case I have in mind I would just
need a key identifier and arbitrary column names where the column name
might include a timestamp+variable_identifier. The whole point is that so I
can see have extremely wide rows at the wonderful performance that
Cassandra has to offer. As of right now, from everything I'm reading in
regards to DataStax recommending CQL over Thrift (I think what I'm
describing is possible with Thrift, but correct me if I'm wrong). That
means I'd have to go AGAINST the recommendation to a protocol that's pretty
much going to eventually not be supported.

Is Cassandra the right tool for that? Are the predefined columns in
documentation nothing more than an example? How does one add a dynamic
column name with an existing column family/table? If I'm stuck with static
columns, how is this any different than using a relational database such as
postgres or mysql? What I found really powerful about Cassandra is being
able to do something like the following in cassandra-cli which uses Thrift:

SET mycf[id]['arbitrary_column'] = 'foo';

However, doing that in CQL isn't possible. Completely limits the way I was
going to model my data for an application and would have no distinct
advantage over a relational database.

Please tell me I'm an idiot and/or am wrong and how I can make this work.
It seems Thrift is the only solution, but I hate going against the
recommended protocol.


View raw message