What is the basic difference between DynamoDB vs Documentdb?

263    Asked by ranjan_6399 in AWS , Asked on Feb 8, 2024

I am working in a particular company that is thinking about migrating its database system to a cloud-based solution. They are considering Amazon Web services and are interested in DynamoDB and documentDB. As a database specialist, how can I advise them in choosing between DynamoDB and documentDB? 

Answered by Daniel BAKER

 In the context of AWS, here are the differences between DynamoDB vs DocumentDB:-

DynamoDB

In this, the applications recurring high scalability with unpredictable workloads

It has real-time data storage and even a retrieval system.

In it, you can use cases where data structures can vary significantly.

It is famous for managing service, which can provide seamless scalability and low latency.

It supports both key-value and even document data models.

Here is the example given of how you can create a DynamoDB table in Python programming language:-

Import boto3

Dynamodb = boto3.resource(‘dynamodb’)
Table = dynamodb.create_table(
    TableName=’example_table’,
    KeySchema=[
        {
            ‘AttributeName’: ‘id’,
            ‘KeyType’: ‘HASH’
        }
    ],
    AttributeDefinitions=[
        {
            ‘AttributeName’: ‘id’,
            ‘AttributeType’: ‘S’
        }
    ],
    ProvisionedThroughput={
        ‘ReadCapacityUnits’: 5,
        ‘WriteCapacityUnits’: 5
    }
)

DocumentDB

In it the applications require MongoDB compatibility.

It has complex queries and even aggregations

You can use it where ACID transactions are necessary.

It is fully managed by MongoDB which is a compatible database service.

It can provide the scalability and even the availability of a distributed database.

It also supports MongoDB API and data models.

Here is the example given of how you can create a DocumentDB by using the command line interface of AWS:-

Aws docdb create-db-cluster 
    --db-cluster-identifier my-docdb-cluster
    --engine docdb
    --master-username admin
    --master-user-password password
    --db-instance-class db.r5.large
    --availability-zones us-east-1a us-east-1b us-east-1c
    --vpc-security-group-ids sg-12345678
You can choose between two according to your requirements.

Your Answer

Interviews

Parent Categories