Primary Keys and Secondary Indexes
Primary Keys
There are either simple
or composite
primary keys.
A simple primary key consists of a single element, called a partition key.
A composite primary key consists of a partition key and a sort key.
A simple primary key is useful for fetching a single item at a time.
A composite primary key lets you fetch many – you can grab all items by a partition key, and further sort on the sort key.
Secondary Indexes
There are two kinds of Secondary Indexes, Local and Global.
Local secondary indexes use the same partition key as your table’s primary key, but a different sort key.
Global secondary indexes can index any attributes you want for partition and sort key.
Local secondary indexes can be strongly consistent, but global secondary indexes can only be eventually consistent.