title: Advice on Converting a Relational Schema to Cassandra
body: <p>I am hoping to get some suggestions on how to best approach converting a typical relational schema to Cassandra. The Relational Schema is:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS sales (
     sale_id     bigint(20) UNSIGNED NOT NULL
                            AUTO_INCREMENT,
     create_time timestamp  NOT NULL
                            DEFAULT ‘0000-00-00 00:00:00’,
     account     bigint(20) UNSIGNED NOT NULL DEFAULT ‘0’,
     store       char(25)   NOT NULL DEFAULT ‘’,
     product     char(25)   NOT NULL DEFAULT ‘’,
     coupon      char(18)   NOT NULL DEFAULT ‘’,
     amount      decimal(8,2) NOT NULL,
     PRIMARY KEY (sale_id),
     KEY         create_time (create_time) )
  </code></pre>
  
  <p>The Cassandra schema I've come up with is:</p>
  
  <pre><code>CREATE TABLE sales (
              sale_id     uuid,
              create_time timestamp,
              account     text,
              store       int,
              coupon      text,
              product     text,
              amount      int,
              PRIMARY KEY ((create_time, store), coupon))
  </code></pre>
  
  <p>(with indexes created on non-key columns I need to query)</p>
  
  <p>Typical query is to get all sales by product by product/coupon/account/store over some time period.</p>
  
  <p>Does this make sense? </p>
  
  <p>Any suggestions on how this may be improved for reasonable read/write performance?</p>
  
  <p>Thanks in advance for any suggestions.</p>