Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cassandra Wiki" for 
change notification.

The "Cassandra2475" page has been changed by EricEvans:
http://wiki.apache.org/cassandra/Cassandra2475

New page:
= CQL Compound Column Proposals =

This page is an attempt to summarize 
[[https://issues.apache.org/jira/browse/CASSANDRA-2474|CASSANDRA-2474: CQL 
support for compound columns]], collecting the most recent versions of each 
proposal, in the hopes that they can be more easily compared.

The names are arbitrary (proposers, feel free to change them), and the ordering 
is based on when/where each appeared in issue 
[[https://issues.apache.org/jira/browse/CASSANDRA-2474|#2474]].

<<TableOfContents(100)>>

== Alpha ==

Discussion starts 
[[https://issues.apache.org/jira/browse/CASSANDRA-2474?focusedCommentId=13046834&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13046834|here]]

=== Goals ===

 * FIXME: add goals
 * FIXME: add goals
 * FIXME: add goals

== Beta ==

Discussion starts 
[[https://issues.apache.org/jira/browse/CASSANDRA-2474?focusedCommentId=13095626&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13095626|here]]

=== Goals ===

 * FIXME: add goals
 * FIXME: add goals
 * FIXME: add goals

== Gamma ==

Discussion starts 
[[https://issues.apache.org/jira/browse/CASSANDRA-2474?focusedCommentId=13171304&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13171304|here]]

=== Goals ===

 * FIXME: add goals
 * FIXME: add goals
 * FIXME: add goals

=== Implementation ===

{{{
CREATE TABLE events (
    series text primary key,
    ts1 int,
    cat text,
    subcat text,
    id uuid
) TRANSPOSED AS (ts1, cat, subcat, id);
}}}

An example column stored might be (2355234412, 'trucks', 'Ford', 
2165cd4c-4db8-4a8f-a2b2-e8fa157f7697). Each transposed row is represented by 
one column.

{{{
CREATE TABLE timeline (
    userid int primary key,
    posted_at uuid,
    posted_by int,
    body text
) TRANSPOSED AS (posted_at), SPARSE(posted_by, body);
}}}

The `SPARSE` keyword means this is a dynamic composite column. Thus, the actual 
composite columns stored here might be {(08ec87a0-2cc3-4982-a0e7-a434884451f8, 
'posted_by'): 524342} and {(08ec87a0-2cc3-4982-a0e7-a434884451f8, 'body'): 'CQL 
FTW'}. That is, the column name literals 'posted_by' and 'body' are part of the 
composite column name. It will take one composite column per SPARSE column to 
store a transposed row.

`SELECT`, `INSERT`, and `UPDATE` syntax requires no changes.  Some examples:

{{{
INSERT INTO timeline (user_id, posted_at, posted_by, body)
VALUES ('tjefferson', '1818', 'jadams', 'Revolution was effected before the war 
commenced');

INSERT INTO timeline (user_id, posted_at, posted_by, body)
VALUES ('tjefferson', '1763', 'jadams', 'Democracy will soon degenerate into an 
anarchy');

INSERT INTO timeline (user_id, posted_at, posted_by, body)
VALUES ('tjefferson', '1790', 'gwashington', 'To be prepared for war is one of 
the most effectual means of preserving peace');

INSERT INTO timeline (user_id, posted_at, posted_by, body)
VALUES ('bfranklin', '1781', 'tjefferson', 'Every government degenerates when 
trusted to the rulers of the people alone');
}}}

The corresponding data model would look like:

||'''user_id'''||'''posted_at'''||'''posted_by'''||'''body'''||
||tjefferson||1818||jadams||Revolution was effected before the war commenced||
||tjefferson||1763||jadams||Democracy will soon degenerate into an anarchy||
||tjefferson||1790||gwashington||To be prepared for war is one of the most 
effectual means of preserving peace||
||bfranklin||1781||tjefferson||Every government degenerates when trusted to the 
rulers of the people alone||

In "raw" form this would look like:

||tjefferson||(1790, 'body'): To be prepared for war is one of the most 
effectual means of preserving peace||(1790, 'posted_by'): gwashington||(1763, 
'body'): Democracy will soon degenerate into an anarchy||(1763, 'posted_by'): 
jadams||(1818, 'body'): Revolution was effected before the war 
commenced||(1818, 'posted_by'): jadams||
||bfranklin||(1781, 'body'): Every government degenerates when trusted to the 
rulers of the people alone||(1781, 'posted_by'): tjefferson||||||||||

And an example `SELECT`:

{{{
SELECT * FROM timeline WHERE user_id = 'tjefferson' AND posted_at > 1770;
}}}

||'''user_id'''||'''posted_at'''||'''posted_by'''||'''body'''||
||tjefferson||1790||gwashington||To be prepared for war is one of the most 
effectual means of preserving peace||
||tjefferson||1818||jadams||Revolution was effected before the war commenced||

=== Advantages ===

 * Language changes are DDL-only
 * FIXME: more advantages
 * FIXME: more advantages

=== Disadvantages ===

 * FIXME: more disadvantages
 * FIXME: more disadvantages
 * FIXME: more disadvantages

Reply via email to