Below is the data which I need to represent in my Cassandra Column Family.
rowKey e1_name e1_schemaname e1_last_modified_date
123 (ByteArray value) abc (some string) some_date
userId
is the rowKey
here. And e1_name
, e1_schemaname
and e1_last_modified_date
are the columns specifically for e1
. All those three columns contain value specifically for e1
column. In the same way, I will be having for another columns such as below.
e2_name e2_schemaname e2_last_modified_date
(ByteArray value) abc (some string) some_date
e3_name e3_schemaname e3_last_modified_date
(ByteArray value) abc (some string) some_date
Now I am thinking- Is there any way to group these three things e1_name
, e1_schemaname
and e1_last_modified_date
into a single column e1
and which will store the composite value together for all the three, instead of storing separately.
If yes, can anyone help me in designing the column family for this? I will be using Astyanax client to insert into above column family.
If I understood correctly, you can design the schema in following way:
columns:
user_id, record_type, name, schemaname, last_modified_date
user_id is your row key (partition key)
record_type or so (e1, e2) might be the cluster key in case e1, e2 are unique within single user. Otherwise your cluster key might be composite including field set for making unique keys
In first case PRIMARY_KEY(user_id, record_type)
e1 e2
123 : {name, schemaname, date } | {name, schemaname, date }
The example for second could be PRIMARY_KEY(user_id, record_type, name)
e1|name e2|name
123 : {schemaname, date } | {schemaname, date }
Does it sounds ok?
Finally I'd say there is a very good official Datastax driver for cassandra native transport: