0

Could you please clarify about ids with cassandra.

In the relational databases use id with auto increment generation. field id is connected to tables mapping, locking. As i know cassandra uses UUID instead Id Could you please explain main concept UUIDs. Why does cassandra exclude ids. Thanks!

student
  • 59
  • 1
  • 6
  • Possible duplicate of [Cassandra: choosing a Partition Key](http://stackoverflow.com/questions/18168379/cassandra-choosing-a-partition-key) – RussS Mar 03 '16 at 21:29

1 Answers1

0

The advantage of UUIDs over auto-incrementing integers is that you can generate them distributed. When using incrementing integers there must be a single counter somewhere that always have to be consulted when generating a new ID. With UUIDs you can just generate a new ID anywhere in your cluster and use it right away.

Basically you can think of UUIDs as big random numbers. So it's highly unlikely that two nodes are generating the same ID even if they are not coordinated.

Still it seems you should make yourself familar on the concepts of the keys in Cassandra. Different to relational databases, keys in Cassandra are not just there for generating a unique identification of a record but to prepare your query for data. Therefore keys in cassandra are often not a UUID … or not a UUID alone.

Matthias Wimmer
  • 3,237
  • 1
  • 19
  • 37
  • Thank you. So, relational database - auto increment for the the primary key http://www.w3schools.com/sql/sql_autoincrement.asp How about cassandra ? Is primary key UUID ? or compound key UUID + some field ? – student Mar 04 '16 at 15:38
  • In Cassandra the primary key is composed by the partition key(s) and the column key(s). Beside being an identification they serve other functions as well: how gets data partitioned and therefore distributed in your cluster, what can be searched for later, and in which order do you want your data returned by Cassandra. Doing all this right is to complicated for a post here on Stackoverflow and actually there are already very good tutorials. I propose you watch at least this course: https://academy.datastax.com/courses/ds201-cassandra-core-concepts – Matthias Wimmer Mar 04 '16 at 15:46