Database Reference
In-Depth Information
-------------------
RowKey: 2
=> (name=, value=, timestamp=1410338757669000)
=> (name=age, value=00000017, timestamp=1410338757669000)
=> (name=name, value=53616d616e746861,
timestamp=1410338757669000)
2 Rows Returned.
Elapsed time: 197 msec(s).
Pretty neat! Two rows with two different unique keys go into two different rows. So, the
CQL representation is the same as the way the data is actually stored (Thrift representa-
tion). But this would not hold true for tables with a compound key. Here's how you create
a table with a compound key:
# Using cqlsh
cqlsh:mastering_cassandra> CREATE TABLE demo_wide_row (id
timestamp , city varchar, hits counter, primary key(id,
city)) WITH COMPACT STORAGE;
cqlsh:mastering_cassandra> UPDATE demo_wide_row SET hits =
hits + 1 WHERE id = '2014-09-04+0000' AND city = 'NY';
cqlsh:mastering_cassandra> UPDATE demo_wide_row SET hits =
hits + 5 WHERE id = '2014-09-04+0000' AND city = 'Bethesda';
cqlsh:mastering_cassandra> UPDATE demo_wide_row SET hits =
hits + 2 WHERE id = '2014-09-04+0000' AND city = 'SF';
cqlsh:mastering_cassandra> UPDATE demo_wide_row SET hits =
hits + 3 WHERE id = '2014-09-05+0000' AND city = 'NY';
cqlsh:mastering_cassandra> UPDATE demo_wide_row SET hits =
hits + 1 WHERE id = '2014-09-05+0000' AND city =
'Baltimore';
cqlsh:mastering_cassandra> SELECT * FROM demo_wide_row;
Search WWH ::




Custom Search