2.3: The importance of item collections

An item collection refers to a group of items that share the same partition key in either the base table or a secondary index.

Primary KeyAttributes
Partition key: ActorSort key: MovieRoleYearGenre
"Tom Hanks""Cast Away""Chuck Noland"2000"Drama"
"Tom Hanks""Toy Story""Woody"1995"Comedy"
"Tim Allen""Toy Story""Buzz Lightyear"1995"Comedy"
"Natalie Portman""Black Swan""Nina Sayers"2010"Drama"

In the table above, we see that there are two movies with the same partition key ie: Tom Hanks. Those two movie items are said to be in the same item collection. Likewise, the single movie role for Natalie Portman is in an item collection, even though it only has one item in it.

Item collections are important for two reasons.

- They are useful for partitioning. DynamoDB partitions your data across a number of nodes in a way that allows for consistent performance as you scale. However, all items with the same partition key will be kept on the same storage node.

- Item collections are useful for data modeling. The Query action can retrieve multiple items within a single item collection. It is an efficient yet flexible operation.