Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate composite column keys/names in Cassandra CQL3
    primarykey
    data
    text
    <p>I would like to create a table in Cassandra using CQL3 queries with structure similar to:</p> <pre><code>myTable myTable_uuid &lt;key_1|second_key_1&gt; : &lt;value_1&gt;, &lt;key_1|second_key_2&gt; : &lt;value_2&gt;, &lt;key_1|second_key_3&gt; : &lt;value_3&gt;, &lt;key_2|second_key_4&gt; : &lt;value_4&gt;, &lt;key_2|second_key_5&gt; : &lt;value_5&gt;, &lt;key_2|second_key_6&gt; : &lt;value_6&gt; PRIMARY KEY(myTable_uuid, first_key_1, first_key_2, second_key_1) </code></pre> <p>Table/CF name is 'myTable' and myTable_uuid is the row key. Additionally I would like to create composite column keys, using CQL3, to be able to group data (key_1 and key_2 form the groups). Is this supported? If yes could someone help me with an example CQL3 query, or the syntax. </p> <p>Purpose: I am trying to design CFs so that data/values are grouped logically, something like the data model explained in Cassandra at ebay blog (<a href="http://www.ebaytechblog.com/2012/07/16/cassandra-data-modeling-best-practices-part-1/" rel="nofollow">http://www.ebaytechblog.com/2012/07/16/cassandra-data-modeling-best-practices-part-1/</a>).</p> <p><em><strong>UPDATE</em></strong></p> <p>I am designing keeping in mind my application and the queries I need. I should have used a real-life query instead of dummy, but here is what I am trying to achieve:</p> <pre><code>myTable myTable_uuid &lt;email|fname&gt; : &lt;value_1&gt;, &lt;email|lname&gt; : &lt;value_2&gt;, &lt;email|age&gt; : &lt;value_3&gt;, &lt;email|timestamp&gt; : &lt;value_4&gt;, &lt;shool_id|school_name&gt; : &lt;value_5&gt;, &lt;shool_id|zip_code&gt; : &lt;value_6&gt; PRIMARY KEY(myTable_uuid, email, school_id, school_name) </code></pre> <p>The <code>&lt;email|fname&gt; , &lt;email|lname&gt;, &lt;email|age&gt;, &lt;shool_id|school_name&gt; and &lt;shool_id|zip_code&gt;</code> would behave as 'Composite Column Keys' and not Row Keys, the table has 'myTable_uuid' as it's Row Key. This approach would help me to group my data into 'email' and 'school_id'. How do I create 'Composite Column Keys' and is it supported to query based on only 1 of the Composite CK? For example:</p> <p><code>SELECT fname, age WHERE email = 'xyz@gmail.com'</code></p> <p>I'm using Cassandra 1.2.6 and CQL3. Any help is appreciated. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload