0

I have to make a key unique in dynamo db. i want to make my email unique, if the email is already existed in database then when i enter next time the same email id then it should not enter to database. it should give a response "email already exists". How can i get that?

This is the response which i am getting an employee..in this example i dont need to insert another email value like [email protected]

{
            "defaultEmp": 0,
            "empName": "Hari",
            "statuses": 1,
            "designation": "store keeper",
            "id": 1,
            "storeId": 1,
            "email": "[email protected]"
        }

2 Answers 2

2

you don't need to make an ID for email to make it unique.. just check the email exists on the db when a user creates an account.. just like that.. no need to make additional field and check it.

Sign up to request clarification or add additional context in comments.

Comments

0

Choose accordingly, what you want to achieve partition key vs composite key.

1: you can use the designation as a partition key and email as a sort key Using sort key.

  • If you want to get all of the email related to single designation this scenario is great.
  • But make sure your design wont end up hitting the only designation otherwise it will end up throttling issue Provision throughput must be divide evenly.

2: you can use the email as a Partition key and designation as a Sort key or only email as Partition key.

  • For a single email what are the designation available

3: simply select email as Partition key.

NOTE:

-make sure email and designation composite Primary key are unique else it will overwrite data.

-This is my first contribution :) Correct me if I am wrong and feel free to give any suggestion. Thanks!

1 Comment

Note: option 3 is the only one where DynamoDb will enforce the unique email requirement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.