When I try to use DynamoDB, I encountered a problem. When a user signup, user will provide email, username, and password. I am using email as partition key in order to make it unique. However, how can I make username unique too?
Query API isn’t work for this situation because user might have different email with same username(which is not what I want to). Instead, I am using scan to scan the table based on username. For now, scan is pretty efficient, but I worry that when the db gets large, scan will fail.
My question is how to make this possible on DynamoDB? 2 or more attributes need to be unique.
Yes, two attributes as composite primary key are possible (more than 2 aren’t). The primary key can either be the partition key (as you have it right now) or the partition key in combination with the sort key, which allows you to have two attributes composing the primary key.