When thinking about how to set up our data structure, think how you would fill in the blanks for the following query: The HASH and RANGE keys allow for a one-to-many like structure - for a single HASH key, there can be multiple RANGE keys. The HASH key is particularly important - you can only grab data for a single HASH key in a Query operation. The HASH key is how your data is partitioned, while the RANGE key is how that data is sorted within a particular HASH key. You then have to specify which attribute is your HASH key and which is your RANGE key. The main difference is that you'll need to define two attributes rather than one. You define the attributes and your key schema when creating the table. Creating a tableĬreating a table with a composite primary key is similar to creating a table with a simple primary key. In the next lessons, we'll work with this data using the Query and Scan API calls. Then, we'll seed it with some data using the BatchWriteItem API call. In this lesson, we'll create a table with a composite primary key. It allows you to work with a group of related items with a single query and enables some powerful use cases. We'll explore this in the context of a DynamoDB table that's using a composite primary key.Ī composite primary key is useful for using DynamoDB as more than a simple key-value store. In this chapter, we're going to work with multiple items at a time. In the previous chapter, we worked with a single Item at a time - inserting, retrieving, updating, and deleting.
0 Comments
Leave a Reply. |