Primary key in cassandra is unique?

DarKAngeL picture DarKAngeL · Feb 13, 2014 · Viewed 14.7k times · Source

It could be kind of lame but in cassandra has the primary key to be unique? For example in the following table:

CREATE TABLE users (
  name text,
  surname text,
  age int,
  adress text,
  PRIMARY KEY(name, surname)
);

So if is it possible in my database to have 2 persons in my database with the same name and surname but different ages? Which means same primary key..

Answer

Daniel picture Daniel · Feb 13, 2014

Yes the primary key has to be unique. Otherwise there would be no way to know which row to return when you query with a duplicate key.

In your case you can have 2 rows with the same name or with the same surname but not both.