AWS Fundamentals LogoAWS Fundamentals
Back to Blog

AWS DynamoDB Data Types

Sandro Volpicella
by Sandro Volpicella
AWS DynamoDB Data Types

Table of Contents

Jump to a section

Amazon DynamoDB is AWS's offering of a fast, scalable, and fully-managed NoSQL database. In DynamoDB you can define data types for your different attributes.

All AWS DynamoDB Data Types

The data types can be separated into three different categories:

  1. Scalar
  2. Document
  3. Set

Scalar Types

AWS DynamoDB Scalar Data Type

Scalar data types represent exactly one value. They are:

Data typeDynamoDB Representation
StringS
NumberN
BinaryB
BooleanBOOL
NullNULL

The DynamoDB JSON representation shows you how the datatypes are represented internally in DynamoDB. The normalized JSON view shows how you would work with the data in applications.

Take the following user table as an example:

AWS DynamoDB User Table Example

You can see the userId is a string (S) while age is a number (N).

DynamoDB JSON

{
    "userId": {
        "S": "123"
    },
    "age": {
        "N": "28"
    },
    "createdAt": {
        "S": "2022-08-20"
    },
    "firstname": {
        "S": "Sandro"
    },
    "lastname": {
        "S": "Volpicella"
    }
}

Normalized JSON

{
    "userId": "123",
    "age": 28,
    "createdAt": "2022-08-20",
    "firstname": "Sandro",
    "lastname": "Volpicella"
}
DynamoDB Infographic

DynamoDB on One Page (No Fluff)

Master NoSQL on AWS. Our DynamoDB cheat sheet covers data modeling, partitioning, and access patterns - the practical knowledge you need.

HD quality, print-friendly. Stick it next to your desk.

Privacy Policy
By entering your email, you are opting in for our twice-a-month AWS newsletter. Once in a while, we'll promote our paid products. We'll never send you spam or sell your data.

Document Types

AWS DynamoDB Document Data Type

Document datatypes have a bit more of a complex structure. They can either be a list (array) or a map (JSON document).

Data typeDynamoDB Representation
ListL
MapM

A list is a simple array of similar or different scalar types. For example, for our user example, we could have a list of all orderIds. This list can contain numbers but it can also contain strings.

DynamoDB JSON

{
    "userId": {
        "S": "123"
    },
    "createdAt": {
        "S": "2022-08-20"
    },
    "firstname": {
        "S": "Sandro"
    },
    "lastname": {
        "S": "Volpicella"
    },
    "orderIds": {
        "L": [
            {
                "S": "123"
            },
            {
                "N": "456"
            }
        ]
    }
}

Normalized JSON

{
    "userId": "123",
    "createdAt": "2022-08-20",
    "firstname": "Sandro",
    "lastname": "Volpicella",
    "orderIds": ["123", "456", "789"]
}

Each item in a list can have a different scalar type. So the list could also look like that: [123, "ORDER", NULL]

Map - This is again a JSON document as an attribute. A common example is to have a subscription object in your user model.

DynamoDB JSON

{
    "userId": {
        "S": "123"
    },
    "createdAt": {
        "S": "2022-08-20"
    },
    "firstname": {
        "S": "Sandro"
    },
    "lastname": {
        "S": "Volpicella"
    },
    "subscription": {
        "M": {
            "customer_id": {
                "S": "cus_123"
            },
            "plan_id": {
                "S": "plan_123"
            }
        }
    }
}

Normalized JSON

{
    "userId": "123",
    "createdAt": "2022-08-20",
    "firstname": "Sandro",
    "lastname": "Volpicella",
    "subscription": {
        "customer_id": "cus_123",
        "plan_id": "plan_123"
    }
}

You can see that the user now has an attribute subscription with a simple object customer_id and plan_id. This makes DynamoDB very powerful.

Set Types

AWS DynamoDB Set Data Type

Set datatypes represent a list of the same scalar value. There are three different set types out there.

Data typeDynamoDB Representation
String SetSS
Number SetNS
Binary SetBS

While a normal list can have different types mixed (like number, string, and NULL). A Set type can only have one type. If we take our orderIds as an example, this would be a String Set

DynamoDB JSON

{
    "userId": {
        "S": "123"
    },
    "createdAt": {
        "S": "2022-08-20"
    },
    "firstname": {
        "S": "Sandro"
    },
    "lastname": {
        "S": "Volpicella"
    },
    "orderIds": {
        "SS": ["123", "456"]
    }
}

Normalized JSON

{
    "userId": "123",
    "createdAt": "2022-08-20",
    "firstname": "Sandro",
    "lastname": "Volpicella",
    "orderIds": ["123", "456"]
}

Final Words

This is all about DynamoDB Data Types. DynamoDB is a really powerful service and makes developing applications on AWS a blast!

If you found this article helpful, you might also enjoy these related posts:

Related Posts

Discover similar content using semantic vector search powered by AWS S3 Vectors. These posts share conceptual similarities based on machine learning embeddings.

vector_search.sh
~/blog/related-posts
$ aws s3-vectors query --embedding-model titan --index bedrock-kb-default --similarity cosine --top-k 3
✓ Found 3 semantic matches:
[MATCH_1]
cosine_similarity:0.504401
vector_dim: 1536 | euclidean_dist: 0.991
How We Built a Social Stats Dashboard Using SST and Next.js
cover.webp...
How We Built a Social Stats Dashboard Using SST and Next.js
aws_service:lambdatimestamp:2024-12-07
slug: /blog/social-stats-dashboard-sst-nextjsembedding_match: 50.44%
[MATCH_2]
cosine_similarity:0.490178
vector_dim: 1536 | euclidean_dist: 1.020
Solutions Architect Associate Exam Cheat Sheet
cover.webp...
Solutions Architect Associate Exam Cheat Sheet
aws_service:lambdatimestamp:2022-09-06
slug: /blog/solutions-architect-associate-exam-cheat-sheetembedding_match: 49.02%
[MATCH_3]
cosine_similarity:0.484052
vector_dim: 1536 | euclidean_dist: 1.032
Amazon DynamoDB CLI - The Complete Guide
cover.webp...
Amazon DynamoDB CLI - The Complete Guide
aws_service:dynamodbtimestamp:2023-06-25
slug: /blog/amazon-dynamodb-cliembedding_match: 48.41%
Query executed in ~10ms
Powered by AWS S3 Vectors
$ _

Related Posts

⚡ Powered by AWS S3 Vectors
DynamoDB Infographic

DynamoDB on One Page (No Fluff)

Master NoSQL on AWS. Our DynamoDB cheat sheet covers data modeling, partitioning, and access patterns - the practical knowledge you need.

HD quality, print-friendly. Stick it next to your desk.

Privacy Policy
By entering your email, you are opting in for our twice-a-month AWS newsletter. Once in a while, we'll promote our paid products. We'll never send you spam or sell your data.