Data Types

Understand the various data types used by the attributes.

We can categorize the data types used by attributes as:

  1. Scalar
  2. Document
  3. Set


The types contained in this category are String, Number, Boolean, Null, and Binary. These data types contain a single value. Let’s look at each one of them.


We can store a string of any size, constrained only by the DynamoDB item size limit. That is, we can store a string of any size as long as your item is less than 400 KB in size. However, if the given string type attribute is used as the primary key, it should be less than 2048 bytes for a single key and 1024 bytes for a composite key.

Examples: “Manager”, “Artist”, and “Read-only”


We can store all numbers with this data type. We can map the basic number types, namely int, double, and float of your programming language to Number in DynamoDB. These numbers can be positive, negative, zero, integer, or decimal.

Examples: 124, 42.34, -5634, and so on.


The value of this attribute can either be true or false.


This is used to represent the null value, i.e. values that are unknown or undefined.


This attribute type is mostly used to store images, documents, or encrypted messages. Binary can also be used as the primary key. The size restrictions are exactly the same as string data type, i.e.,

  • Total item size should be less than 400 KB
  • When used as a primary key, it should be less than 2048 bytes and 1024 bytes for single and composite keys respectively.


These are collection data types. There are two types of collections supported by DynamoDB, namely: List and Map.


A map is a collection of key-value pairs. We can think of it as similar to a JSON object. These key-value pairs are not ordered.


A list is a collection of values. The values can be of the same type or different types. We can think of this collection as similar to Python lists. The elements in this data type are ordered. We can get the elements by their index.


Sets in DynamoDB are the same as lists but with some added restrictions. All of the elements in the set should be of the same type and should be unique. Unlike List, the elements are not ordered. There are three types of Sets in DynamoDB depending on the data types of list elements:

  1. NumberSet: Elements are Numbers
  2. StringSet: Elements are Strings
  3. BinarySet: Elements are Binary objects

Sets have a size restriction, according to which the size of the item should not exceed 400KB.