MongoDB migration to DynamoDB

0

Hello,

I ask these questions because I couldn't found much information about used case or best answers about migration MongoDB to DynamoDB.

  • Does DynamoDB support ObjectId, which is used as a unique key in existing MongoDB, in a similar form?

  • Is it a good way to store partition keys by dividing them by geographical criteria when designing a global table?

  • If I want to build a DynamoDB table as a global table, is the Global Secondary Index an essential part of the design?

  • Should the sort key be used for all items that are subject to the query conditions among queries that query the collection in the existing MongoDB?

It will be so helpful if you guys give some advice of those questions or commend

Thank you so much

3 Answers
0

The Partition Key is a Hash key used to shard so you have to be careful & creative with its design to ensure it's well-distributed; so certain values & hence partitions don't get overloaded. Generally you'd want something more fine-grained than geographical criteria but it depends on the use case. Also note a table's primary key must be unique; it can be either the Partition Key or Partition Key + Sort Key.

The attributes in your Sort Key depend on the specific queries you want to run. Design that plus secondary indexes to support the queries.

A Global Secondary Index is called "Global" because, as opposed to a Local Secondary Index, it allows you to retrieve across partitions instead of local to one partition. It's not related to Global Tables.

EXPERT
answered a year ago
0

In addition to what @skinsman already mentioned, you should have a read at https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/best-practices.html where you find detailed information on best practices for defining your tables and indexes in DynamoDB.

For an hands-on learning experience, have also a look at https://amazon-dynamodb-labs.workshop.aws/

AWS
EXPERT
answered a year ago
0

Hi, Before answering the qns I want to set the context for DynamoDB. First of all, DynamoDB is a key value store unlike MongoDB, which is a document database. DynamoDB works on a distributed architecture wherein the data is partitioned and spread across multiple partitions using something called Partition Key. Partition key and Sort key play a cornerstone role in designing DynamoDB schema. DynamoDB schema design works on a few tenets - 1) Understanding the use case; 2) Identification of access patterns or query patterns; 3) Iterative approach on data modeling and schema design;

Does DynamoDB support ObjectId, which is used as a unique key in existing MongoDB, in a similar form? - DynamoDB has primary key (simple - Partition Key; composite - Partition Key + Sort Key), which can be used to uniquely identify each and every items in the table. But it is not self created like MongoDB, it has to be populated by the application.

Is it a good way to store partition keys by dividing them by geographical criteria when designing a global table? - Partition key and Global table does not have correlation. In case of Global table, all records will be there in all the regions that are added as part of Global table.

If I want to build a DynamoDB table as a global table, is the Global Secondary Index an essential part of the design? - This is where point no. 2 (identification of access patterns) becomes paramount. Global secondary index (GSI) plays a role in the schema design based on the access patterns. Global tables and GSIs have no correlation vis-a-vis design.

Should the sort key be used for all items that are subject to the query conditions among queries that query the collection in the existing MongoDB? - It is better to have sort key for all items, which gives flexibility in data modeling. What should be the sort key and how it would be used would completely depend on the queries and the access patterns that you are trying to solve.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions