Amazon-Dynamodb [SOLVED]: How to make DynamoDB attribute unique?

Amazon-Dynamodb [SOLVED]: How to make DynamoDB attribute unique?

Home Forums Amazon Web Services Amazon Dynamodb Amazon-Dynamodb [SOLVED]: How to make DynamoDB attribute unique?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #247020

    Cloudy Point
    Keymaster

    QuestionQuestion

    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.

    #247021

    Cloudy Point
    Keymaster

    Accepted AnswerAnswer

    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.

    For details check out the DynamoDB documentation for primary keys.

    Source: https://stackoverflow.com/questions/47958071/how-to-make-dynamodb-attribute-unique
    Author: Dunedan
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.