Create composite column keys/names in Cassandra CQL3 -
i create table in cassandra using cql3 queries structure similar to:
mytable mytable_uuid <key_1|second_key_1> : <value_1>, <key_1|second_key_2> : <value_2>, <key_1|second_key_3> : <value_3>, <key_2|second_key_4> : <value_4>, <key_2|second_key_5> : <value_5>, <key_2|second_key_6> : <value_6> primary key(mytable_uuid, first_key_1, first_key_2, second_key_1)
table/cf name 'mytable' , mytable_uuid row key. additionally create composite column keys, using cql3, able group data (key_1 , key_2 form groups). supported? if yes me example cql3 query, or syntax.
purpose: trying design cfs data/values grouped logically, data model explained in cassandra @ ebay blog (http://www.ebaytechblog.com/2012/07/16/cassandra-data-modeling-best-practices-part-1/).
update
i designing keeping in mind application , queries need. should have used real-life query instead of dummy, here trying achieve:
mytable mytable_uuid <email|fname> : <value_1>, <email|lname> : <value_2>, <email|age> : <value_3>, <email|timestamp> : <value_4>, <shool_id|school_name> : <value_5>, <shool_id|zip_code> : <value_6> primary key(mytable_uuid, email, school_id, school_name)
the <email|fname> , <email|lname>, <email|age>, <shool_id|school_name> , <shool_id|zip_code>
behave 'composite column keys' , not row keys, table has 'mytable_uuid' it's row key. approach me group data 'email' , 'school_id'. how create 'composite column keys' , supported query based on 1 of composite ck? example:
select fname, age email = 'xyz@gmail.com'
i'm using cassandra 1.2.6 , cql3. appreciated.
yes, supported. cql3 supports features. (except deleting columns, fixed pretty soon, not take storage in meanwhile , off-topic).
in cql3, composite column keys created adding them primary keys clause. first key given forms row key, following columns form (composite) column key. blog entry explains well.
create table mytable ( myid uuid, key_1 varchar, key_2 varchar, value varchar, primary key (myid, key_1, key_2) );
thus, myid partition key , key_1 , key_2 "group" data , form composite column key.
hope helps.
Comments
Post a Comment