Skip to content

Instantly share code, notes, and snippets.

View tunggnu's full-sized avatar
🏠
Working from home

Tom Nguyen tunggnu

🏠
Working from home
  • Hanoi, Vietnam
View GitHub Profile
@tunggnu
tunggnu / gist:33b452465f17be366bd7e972d6cefc42
Created November 23, 2023 16:17 — forked from roubles/gist:79ede5f7410b0ff4c44046f1f50838c8
A pattern for creating a reliable unique constraint in Cassandra

Unique Constraints in Cassandra

Cassandra is a NoSQL database, and is meant for different applications than traditional relational databases. Nevertheless, developers will want (and try) to implement RDBMS features in Cassandra. Unique constraints is one such example.

Many people have asked about creating unique constraints in Cassandra: 1, 2, 3, 4. There is no definitive answer. The most popular answer seems to be to not even try it. Square peg, round hole. If you need unique constraints, Cassandra may not be the tool for the job. Others have suggested to use LWT/CAS. It should be noted that, simply using LWT/CAS does not give us reliable unique constraints that we get i