1
votes

Using CQL3, is it possible to define multiple formats of composite columns within a table/column family? With the syntax:

PRIMARY KEY(A, B, C)

it looks like A becomes the row key, a composite column of B:C is created, and additional composite columns are created for each additional column with B:C prepended.

What if I wanted to have in that same column family, another composite column X:Y - can that be accomplished?

2

2 Answers

1
votes

I am not sure if that is possible using CLI. But we are using PlayOrm for Cassandra and there it is very much possible. Basically, you can have millions of composite columns. Read this for more details. The example is given for a OneToMany relation where you can have multiple column with name like activities.act1, activities.act2. Similarly you can have more entities with *ToMany relationship and can save them in composite column. If you do not want to use *ToMany relationship, then you may try its @NoSqlEmbedded pattern which also stores the data in composite columns.

0
votes

Primary key identifies the single row of the table (all listed components). The A is a partition key that defines the placement of this partition on particular server.

In CQL3 you have only one primary key per table/column family. If you need to access it differently, you may (with some limitations) use the materialized views, or duplicate data into separate table.