Hi,

I know this is a pretty common topic, but I haven't found any solution that
really satisfy me. The problem is well known: you have a table with user
information with a UUID as primary key, but you want to avoid email
duplicates when new users register.

The closest solution I've found is this:

https://www.mail-archive.com/user@cassandra.apache.org/msg19766.html

It achieves the goal of avoiding confirmed users account with the same
email, but I think that does not avoid malicious users to fill your user
table with pending registrations (if you don't confirm any). I know that
this is a minor thing, but anyway.

I have though of a solution and it would be great if you could confirm that
it is a good one. Assume you have a table with the user information with a
UUID as primary key, and an "index" table email_to_UUID with email as
primary key.

When a user registers, the server generates a UUID and performs an INSERT
... IF NOT EXISTS into the email_to_UUID table. Immediately after, perform
a SELECT from the same table and see if the read UUID is the same that the
one we just generated. If it is, we are allowed to INSERT the data in the
user table, knowing that no other will be doing it.

Does this sound right ? Is this the right way to have sort of UNIQUE
columns ?

Thanks in advance

Reply via email to