| **Partition Key** |
The partition key identifies a logical partition in a distributed storage that a data item is stored in. These logical partitions are mapped to physical storage nodes in the backend through hash functions.
In the sample table *Menu* discussed below, the attribute Category is a partition key. |
| **Sort Key** |
The primary sort key sorts through a specific partition to locate a data item and returns it in a sorted order if more than 1 item matches with the partition key in the data. This is done by identifying it from a range of key hashes. Catalyst enables you to add a sort key optionally while creating a NoSQL table.
In the sample table *Menu* discussed below, the attribute `DishName` is regarded as a sort key. |
| **Simple Primary Key** |
A simple primary key in Catalyst NoSQL denotes the partition key alone.
When you choose to only configure a partition key for a NoSQL table without a sort key, the partition key will act as the primary key of the table by uniquely identifying an item in it. This is similar to the concept of a primary key in a relational database.
In the sample table *Travel* discussed in the previous section, the attribute `DestinationName` is regarded as the primary key, as this attribute must be present in all items and no two items with the same values for this attribute can exist.
However, in the sample table *Menu* discussed below, the partition key `Category` does not uniquely identify an item, because multiple items can exist with the same value for it. This is because the *Menu* table uses a composite primary key.
|
| **Composite Primary Key** |
The composite primary key includes both a partition key and a sort key to uniquely identify an item, i.e., the combination of both keys act as a primary key. Querying a table with the composite primary key is global, as the data spans across multiple partitions.
Unlike the simple primary key which requires the partition key to be unique, you can store non-unique values for the partition key here, as long as you define a sort key as well.
> **Note:** For all the items that have the same partition key in a table, the sort keys must be unique.
The sample table *Menu* discussed below contains a composite primary key wherein the partition key `Category` and the sort key `DishName` together uniquely identify a data item (a dish). |
| **Additional Sort Keys** |
Catalyst NoSQL allows you to configure additional sort keys, besides the main sort key, which is a part of the composite primary key.
Additional sort keys are used if you require the sorting to be performed based on a different key besides the main sort key, or if the main sort key is unknown for a specific item. In this case, a combination of the partition key and an additional sort key will be used as a composite primary key.
Querying a table with additional sort keys are similar to local indexing, as they are all used with the same partition key to sort in that specific partition alone.
> **Note:** Catalyst allows you to configure a **maximum of 5 additional sort keys** for a table.
In the sample table *Menu* discussed below, the attributes `PreparationTime` and `Calories` are configured as additional sort keys. |