I’m not sure I understand correctly “for example column.name would be
event_name("temperature")“, what I gather however is that you have multiple
events that may or may not have certain properties, in your example I
believe you mean you want a CF for events with a type event_name that
contains a column temperature ?!

You can model it like that :

CREATE TABLE events (
  name text,
  metric text,
  value text,
  PRIMARY KEY (name, metric)
)

Where

   - name is the row key, for each kind (or name) of event
   - metric is the column name, aka the clustering key

For example when inserting

INSERT INTO events (name, metric, value) VALUES ('captor',
'temperature', '25 ºC');
INSERT INTO events (name, metric, value) VALUES ('captor', 'wind', '5 km/h');
INSERT INTO events (name, metric, value) VALUES ('captor',
'atmosphere', '1013 millibars');

INSERT INTO events (name, metric, value) VALUES ('cpu', 'temperature', '70 ºC');
INSERT INTO events (name, metric, value) VALUES ('cpu', 'frequency',
'1015,7 MHz');

You will have something like this :
  temperature atmosphere wind frequency   meteorologic 25 ºC 1013 millibars 5
km/h  cpu 70 ºC  1015,7 MHz

CQLSH represents each clustering key as row, which is not how the column
family is stored.

The model I give is just an example as you may want a to model differently
according to your use cases. And time probably is part of it. And will
probably be in the clustering key too.

Note that if you create wide rows and you have *a lot* of data, you may
want to bucket the CF per time period (month / week / day / etc).

HTH

— Brice

On Thu, Sep 25, 2014 at 3:13 PM, shahab <shahab.mok...@gmail.com> wrote:

Thanks,
> It seems that I was not clear in my question, I would like to store values
> in the column name, for example column.name would be event_name
> ("temperature") and column-content would be the respective value (e.g.
> 40.5) . And I need to know how the schema should look like in CQL 3
>
> best,
> /Shahab
>
>
> On Wed, Sep 24, 2014 at 1:49 PM, DuyHai Doan <doanduy...@gmail.com> wrote:
>
>> Dynamic thing in Thrift ≈ clustering columns in CQL
>>
>> Can you give more details about your data model ?
>>
>> On Wed, Sep 24, 2014 at 1:11 PM, shahab <shahab.mok...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I  would like to define schema for a table where the column (cell) names
>>> are defined dynamically. Apparently there is a way to do this in Thrift (
>>> http://www.datastax.com/dev/blog/does-cql-support-dynamic-columns-wide-rows
>>> )
>>>
>>> but i couldn't find how i can do the same using CQL?
>>>
>>> Any resource/example that I can look at ?
>>>
>>>
>>> best,
>>> /Shahab
>>>
>>
>>
>  ​

Reply via email to