All our DynamoDB articles collected in one place.
DynamoDB OneTable (OneTable) is an access library for DynamoDB applications that use one-table design patterns with NodeJS.
OneTable makes dealing with DynamoDB and one-table design patterns dramatically easier while still providing easy access to the full DynamoDB API.
DynamoDB OneTable Overview Tour
This overview tour describes the OneTable overview working sample. Step along in VS code with a working sample.
We've worked very hard to make the OneTable API expressive, terse and elegant to use. I hope you will find that it makes your DynamoDB developments proceed faster and more easily than every before.
Using DynamoDB with OneTable Schemas
DynamoDB is a key-value and document database that does not enforce a schema for your data. You can store data items where each item may have different attributes and attribute types. Item values may be primitive values, scalars or compound documents.
The DynamoDB OneTable Library enables you to define your single-table entity definitions via a OneTable schema. This makes understanding and working with single-table designs dramatically easier and allows another layer of capabilities over the raw DynamoDB engine.
Data Modeling for DynamoDB
DynamoDB best practices have evolved around single-table design patterns where one database table serves the entire application and holds multiple different application entities.
This design pattern offers greater performance by reducing the number of requests required to retrieve information and lowers operational overhead. It also greatly simplifies the changing and evolving of your DynamoDB designs by uncoupling the entity key fields and attributes from the physical table structure.
DynamoDB with Typescript
DynamoDB is increasingly being used with TypeScript where it provides strong API checks and guarantees. However, is natural to want TypeScript type support for both the API and the data entities that are passed to and from the database.
This post discusses how the DynamoDB OneTable library uses dynamic TypeScript support fully type check DynamoDB data and achieve an elegant solution.
DynamoDB GSI Attribute Packing
[DynamoDB single-table] designs store multiple entities with different named attributes in a single table. It can be difficult to decide which attribute names should be projected to GSIs as the set of names across the different entities may be large. Furthermore, you cannot change the names of projected attributes after you create the GSI. These issues makes efficient use GSIs more difficult and complicates evolving and changing your design.
OneTable solves this problem by supporting the mapping of different entity attribute into a single GSI projected attribute. It also permits packing multiple attributes into a single GSI attribute.
DynamoDB Sparse Indexes
DynamoDB provides secondary indexes for fast access via alternate partition and sort keys. By using sparse secondary indexes, you can minimize your DynamoDB storage costs and not compromise on having fast, efficient queries. You can also improve your ability to evolve your data designs in the future.
Using DynamoDB OneTable makes retrieving data from sparse, key-only secondary indexes easy and cost effective. It provides a transparent
follow option to retrieve complete data items via sparse, keys-only indexes.
Evolving DynamoDB Designs
Conventional wisdom seems to be that changing a DynamoDB design is extremely difficult and you want to avoid it at all costs.
However, with single table designs, this thinking is out of date and today, is just plain wrong.
With single table DynamoDB designs, your keys and attributes are uncoupled from the physical implementation, so you can evolve your DynamoDB design much more easily.
OneTable CLI for Migrations
The CLI is ideal for development teams to initialize and reset database contents and for production use to control and sequence step-wise database upgrades.
This DynamoDB checklist is a collection of the some of the more important items I've learned with our SenseDeep serverless developer studio that uses single-table design patterns, NodeJS and the DynamoDB OneTable library in production over the past year.
I hope you will consider them in your DynamoDB projects and use it as a checklist to prompt your adoption of best practices.