Now imagine that a user has lost his/her username, but the user remembers his/her e-mail ID. You just keyed everything on the username, so without it we are lost. You can read all the entries in the database in the attempt of finding this e-mail ID. However, I don't have to convince you how bad this approach is.
So, I challenge you to design your approach. Most of my students, when presented with this challenge in class, started changing the basic user
table, preparing it for additional queries. However, the right approach is more radical. Here's some advice from one of the leading NoSQL architects, Patrick McFadin:
"Good question! (We are not alone in our struggle)."
I mention this topic in other venues, too. What do you do if you want to look up by e-mail ID? This might be a good place for an index table, as follows:
create table email_index ( domain text, username text, user_id text, PRIMARY KEY (domain, username) );
So, with an address such...