On 02/24/2014 09:00 PM, John Stager wrote:
Hello,
We are working on our data model for Cassandra and we have a need to use
surrogate keys (timeuuid) and not the natural key for one of our tables
but this causes a possible timing issue when determining if a row
already exists.Are there any best practices or patterns for Cassandra
for using surrogate keys?
This is the classic user id (surrogate key) and username (email address).
This sounds like the perfect use case for lightweight transactions and
just using timeuuid. LWT are more expensive due to read before write,
but when needed, as in your case, it's the right fit. Even with
perfectly time-synced nodes, there is still a race for two users to
create the same userid, which is why LWT was included.
http://www.datastax.com/dev/blog/lightweight-transactions-in-cassandra-2-0
http://www.datastax.com/documentation/cassandra/2.0/cassandra/dml/dml_ltwt_transaction_c.html
--
Kind regards,
Michael