incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tristan Seligmann <>
Subject Re: Using CQL to insert a column to a row dynamically
Date Tue, 28 May 2013 08:45:18 GMT
On Mon, May 27, 2013 at 11:38 PM, Matthew Hillsborough <> wrote:

> Originally what I thought of doing was creating a column family in
> Cassandra named `ride_events`. Each row key would be a rideID that's simply
> an integer. I would then arbitrarily create columns with a name of the
> following format:
> "EventID_5/Day_2/User_6" with a value of null.

You can accomplish the same thing with a CQL 3 schema like this:

CREATE TABLE ride_events (
  rideID int,
  eventID int,
  day int,
  userID int,
  dummy text,
  PRIMARY KEY (rideID, eventID, day, userID));

(I'm not sure if the `dummy` column is still required, it was last time I
tried this).

rideID will then be used as the partition key (underlying row key), while
eventID / day / userID will be composited into the underlying storage
engine column names.

An example query against this schema might be:

SELECT userID FROM ride_events WHERE rideID in (...) AND eventID = 5 AND
day = 2;
mithrandi, i Ainil en-Balandor, a faer Ambar

View raw message