I am going from SQL to NoSQL with Cassandra.
I’ve read Do You Really Need SQL to Do It All in Cassandra?. That speaks about sql select, join, group by and order by, but there is nothing about the “id” concept in sql data base. In SQL, all values have an unique identifier.
Is there something like that with nosql/cassandra? What? Is it safe to do something like newId = lastId + 1 or something like that with Cassandra and how?
Thanks.
IDs doesn’t exist in Cassandra. It is a simple key / value store you need to provide you with your own document IDs (called keys). The suggested approach is to use UUIDs, which are designed to avoid conflicting keys.
Doing something like
newId = lastId + 1is not safe at all. Cassandra doesn’t, by design, support transactions, and no way to make read + write atomic. Concurrent transactions can make this fail:If you’re interested, Cassandra Counters addresses this issue.