Another advantage of UUIDs
As it turns out, the users table is the only table in the MyStatus keyspace that has this problem. All the other tables use UUIDs in their primary keys; since UUIDs are guaranteed to be globally unique, we simply don't have to worry about what might happen in the case of a primary key collision.
UUIDs are great in the case where the table doesn't have a natural key, as we discussed in Chapter 2, The First Table. However, using a UUID key in the users table won't solve the fundamental problem, since we still want to guarantee that usernames are unique. A username collision would be less catastrophic, since at least we wouldn't overwrite data. However, we'd have also forfeited the only structure Cassandra gives us ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access