# SchemaOptions

Represents the table schema attributes.

Returned by: [Table.schema](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.Table.html#schema)

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

## Example

TypeScript:

```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 schemaOptions: dynamodb.SchemaOptions = {
  partitionKey: {
    name: 'name',
    type: dynamodb.AttributeType.BINARY,
  },
  sortKey: {
    name: 'name',
    type: dynamodb.AttributeType.BINARY,
  },
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_dynamodb as dynamodb

schema_options = dynamodb.SchemaOptions(
    partition_key=dynamodb.Attribute(
        name="name",
        type=dynamodb.AttributeType.BINARY
    ),
    sort_key=dynamodb.Attribute(
        name="name",
        type=dynamodb.AttributeType.BINARY
    )
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.dynamodb.*;

SchemaOptions schemaOptions = SchemaOptions.builder()
        .partitionKey(Attribute.builder()
                .name("name")
                .type(AttributeType.BINARY)
                .build())
        .sortKey(Attribute.builder()
                .name("name")
                .type(AttributeType.BINARY)
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.DynamoDB;

var schemaOptions = new SchemaOptions {
    PartitionKey = new Attribute {
        Name = "name",
        Type = AttributeType.BINARY
    },
    SortKey = new Attribute {
        Name = "name",
        Type = AttributeType.BINARY
    }
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

schemaOptions := &SchemaOptions{
	PartitionKey: &Attribute{
		Name: jsii.String("name"),
		Type: awscdk.Aws_dynamodb.AttributeType_BINARY,
	},
	SortKey: &Attribute{
		Name: jsii.String("name"),
		Type: awscdk.*Aws_dynamodb.AttributeType_BINARY,
	},
}
```

## Properties

- `partitionKey`: [Attribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.Attribute.html) — Partition key attribute definition.

  **Default:** exactly one of `partitionKey` and `partitionKeys` must be specified.

  If a single field forms the partition key, you can use this field.  Use the
  `partitionKeys` field if the partition key is a multi-attribute key (consists of
  multiple fields).

- `sortKey`: [Attribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.Attribute.html) — Sort key attribute definition.

  **Default:** no sort key

  If a single field forms the sort key, you can use this field.  Use the
  `sortKeys` field if the sort key is a multi-attribute key (consists of multiple
  fields).
