0
0
AwsHow-ToBeginner · 4 min read

How to Create a DynamoDB Table Using AWS Console

To create a DynamoDB table in the AWS Console, open the DynamoDB service, click Create table, enter a Table name and Primary key, then configure settings like capacity mode and indexes before clicking Create. This sets up your table ready to store and retrieve data.
📐

Syntax

Creating a DynamoDB table in AWS Console involves these main parts:

  • Table name: A unique name for your table.
  • Primary key: Defines how items are uniquely identified. It can be a simple key (partition key) or composite key (partition key + sort key).
  • Capacity mode: Choose between On-demand (pay per request) or Provisioned (set read/write units).
  • Secondary indexes: Optional indexes to query data efficiently.
  • Encryption and tags: Optional security and metadata settings.
text
Create table with:
- Table name: string
- Primary key: partition key (string or number), optional sort key
- Capacity mode: On-demand or Provisioned
- Optional: secondary indexes, encryption, tags
💻

Example

This example shows how to create a DynamoDB table named Books with a partition key ISBN of type string, using On-demand capacity mode.

text
1. Sign in to AWS Management Console.
2. Open the DynamoDB service.
3. Click on 'Create table'.
4. Enter 'Books' as Table name.
5. Set Partition key as 'ISBN' with type 'String'.
6. Choose 'On-demand' for capacity mode.
7. Leave other settings as default.
8. Click 'Create table'.
Output
Table 'Books' is created and ready to use with On-demand capacity and primary key 'ISBN'.
⚠️

Common Pitfalls

Common mistakes when creating DynamoDB tables include:

  • Choosing a poor primary key that does not uniquely identify items, causing data overwrite.
  • Using Provisioned capacity without estimating traffic, leading to throttling or extra costs.
  • Forgetting to add secondary indexes when needed for queries, limiting data access patterns.
  • Not enabling encryption if data security is required.

Always plan your keys and capacity based on your app needs.

text
Wrong:
- Primary key: 'Category' (not unique)
Right:
- Primary key: 'OrderID' (unique per item)
📊

Quick Reference

SettingDescriptionExample
Table nameUnique name for the tableBooks
Partition keyPrimary key attribute name and typeISBN (String)
Sort keyOptional secondary key for sortingAuthor (String)
Capacity modeOn-demand or ProvisionedOn-demand
Secondary indexesOptional indexes for queriesGSI on Author
EncryptionEnable encryption at restAWS owned CMK

Key Takeaways

Use the AWS Console DynamoDB service to create tables with a clear table name and primary key.
Choose On-demand capacity mode for flexible billing or Provisioned for predictable workloads.
Plan your primary key carefully to avoid data conflicts and support your queries.
Add secondary indexes if you need to query data by attributes other than the primary key.
Enable encryption and tags for security and management best practices.