# KeySchema

A description of a key schema of an LSI, GSI or Table.

- Source: [`aws-dynamodb/lib/shared.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-dynamodb/lib/shared.ts#L571)
- Type last changed: v2.226.0 · 20 Nov 2025

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_dynamodb as dynamodb } from 'aws-cdk-lib';
const keySchema: dynamodb.KeySchema = {
  partitionKeys: [{
    name: 'name',
    type: dynamodb.AttributeType.BINARY,
  }],
  sortKeys: [{
    name: 'name',
    type: dynamodb.AttributeType.BINARY,
  }],
};
```

## Properties

- `partitionKeys`: [Attribute](/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.Attribute.html)[] (required) — Partition key definition.

  This array has at least one, but potentially multiple entries.  Together,
  they form the partition key.

- `sortKeys`: [Attribute](/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.Attribute.html)[] (required) — Sort key definition.

  This array has zero or more entries. Together, they form the sort key.
