Amazon DynamoDB Data Modeler

☰ menu
× Create Model Clear Model Load from File Save to File Set Credentials Import OneTable Export OneTable

Introduction

Welcome to the DynamoDB Data Modeler. This utility creates a data model with one or more virtual Tables, allowing users to visualize how relational data might be stored and indexed in DynamoDB in order to help design efficient schema for your application. The tool is fully compatible with the NoSQL Workbench for DynamoDB, and models generated by either tool are interchangeable. Any changes made in either tool can be easily exported and loaded into the other to facilitate collaboration with users who may be working in environments that do not allow installation of desktop applications like NoSQL Workbench for DynamoDB.

The data displayed by the DynamoDB Data Modeler is stored locally in memory as a collection of virtual Tables, allowing complex data models to be easily constructed and validated without requiring resources to be created in an AWS account space. Unlike other tools for visualizing data, both the DynamoDB Data Modeler online tool and the NoSQL Workbench for DynamoDB are designed specifically to model NoSQL data and do not assume that the items being displayed are homogenous in nature. The Table will display many types of items as a single aggregated view representing a DynamoDB data model.

Getting Started

To get started with a new model, select 'Create Model' from the options menu. To import an existing model use the 'Load Model' option. When 'Create Model' is selected you will be prompted to provide a Model Name, Author and Description and then asked to define the first Table in the Data Model. When a new Table is defined, the DynamoDB Data Modeler wiill build an empty Table with a single Item that looks similar to the following image:




Using the Amazon DynamoDB Data Modeler

Certain elements in the Table view are decorated with controls that can be used for the following actions:

Click the swap '' control to add a new Table or select an existing Table from the current Model to view.

Click the binoculars '' control to define and run a query against the sample data loaded in the modeler.

Click the back '' control to undo a change to the currently selected Table. The modeler caches up to 50 changes for each Table in the currently loaded Model. The change cache is cleared when a new Model is loaded.

Click the wrench '' control to switch to 'schema view' to edit attribute types and Value Templates. See 'Editing Schema' section below for details.

Click the sliders '' control to switch back to 'values view' and edit attribute values.

Click the plus '' control:

  1. On the Table Name tab to create a new index:


  2. In the Primary Key header cell to add a new partition:


  3. In a Partition Key value cell to add a new item to a partition:


  4. In a Sort Key value cell to add a new attribute to an Item:


Finally, click the minus '' control:

  1. In a Partition Key value cell to delete a partition and all Items in it:


  2. In a Sort Key value cell to delete an Item:


The following image shows a data model for tracking patients, room assignments, and treatments for a hospital resource scheduling service originally created in NoSQL Workbench for DynamoDB (Hospital.json):



Clicking the add '' symbol in the "Primary Key" field of the Table header will add a new Item to the bottom of the Table, as shown in the following image



Clicking the add '' symbol in an existing Partition Value cell or changing the PK value of a new or existing Partition will move or create Items in the specified Partition.



Changing the "type" attribute value will cause the Item to be annoted with attributes from the corresponding Item template:



Clicking the add '' symbol in a Sort Key value cell will add a new attribute to the Item. When new attribtes are added to an existing Item the Attribute Name becomes editable:



When the attribute name is assigned, all objects of that type will be annotated with the new attribute:



The modeler uses custom code to maintain an editable HTML Table, and there are probably a few bugs that still need to be worked out. If you edit a model and something goes wrong you can hit the back arrow in the Attributes area of the Table header to undo up to 50 changes.

Item Types

All Items created by the DynamoDB Data Modeler have a "type" attribute added automatically, and the modeler maintains an attribute template for each unique Item type detected. As new Items are added to the tool they will inherit the template attributes for the specified Item type, and adding an attribute to any object will also update the template for that object type as well as cause other Items of that type to be annotated with the new attribute.

Context Menus

Every attribute on the table has a Context Menu that can be accessed via right click on the attribute value. The options available on the context menu differ depending on whether the attribute is the Partion Key, Sort Key, or generic.

Partition Key Menu



The Partition Key Context Menu contains the following options:

  1. Add Item - Adds a new Item to the partition.
  2. Paste Item - Adds a copied Item to the partition.
  3. Delete Partition - Deletes all Items in this partition from the table.
  4. Edit Value Template - Define a value template to generate the Partition Key value.
  5. Move Up/Down - Change the position of the partition on the table.

Sort Key Menu



The Sort Key Context Menu contains the following options:

  1. Add Attribute - Adds a new Attribute to the Item.
  2. Cut Item - Removes the Item from the Table and copies it to the clipboard.
  3. Copy Item - Copies the Item to the clipboard.
  4. Delete Item - Removes the Item from the Table.
  5. Edit Value Template - Define a value template to generate the Sort Key value.
  6. Generate Value - Inserts either an ISO Date or UUID string as the Sort Key value.

Attribute Menu



The Attribute Context Menu contains the following options:

  1. Delete Attribute - Removes the Attribute from the Item.
  2. Cut Item - Removes the Item from the Table and copies it to the clipboard.
  3. Edit Value Template - Define a value template to generate the Attribute value.
  4. Generate Value - Inserts either an ISO Date or UUID string as the Attribute value.

Schema View

Toggling the wrench '' icon on the right of the table will display the Schema Models of the object types associated with the sample data. When displaying the "Schema" view, the attribute types and values templates are displayed instead of the table values. Click the sliders '' icon to return the Data View.




Value Templates

Attributes can be assigned value templates to generate values. Value templates are associated to Attributes by Item type. When an Item is created or modified the type of the Item will determine any value templates that should be used to generate Attribute values. Value Templates can be assigned directly by editing values in the "Schema" view or via dialog by selecting the "Edit Value Template" option from the context menu. Assigning a Value Template to an attribute will apply the template to all Items of the same model type.

Currently the only operation supported for value template is concatenation of other Attributes into a composite attribute. To combine Attribute values simply reference the attribute name using '${name}' as shown in the screenshot. Any text outside of the '${}' syntax will appear as typed in the final value. In the model defined below the Value Template for the Item attribute 'SK' of the 'treatment' Schema Model is defined as follows:

"${timestamp}#${treatmentId}"

This will cause the modeler to generate an 'SK' attribute with a value similar to "2020-11-25T12:00:00#T1" using the values of the 'timestamp' and 'treatmentId' attributes for any Item with a 'type' value of 'treatment'.




OneTable Integration

If you use OneTable you can now import and export your schema files to/from the DynamoDB Modeler using the convenient links on the Side Panel menu. To import, simply click the import link and specify the location of your OneTable json or javascript schema file. The modeler will convert any data objects from OneTable format and load all the ValueTemplates and Shema models defined in the OneTable schema. After the schema is imported you will be able to create Items using OneTable model types. Exported schemas are saved to a file in a multi-line JSON format.

That should be enough to get you going. Click the '☰ menu' icon in the upper right corner to import an existing model from NoSQL Workbench for DynamoDB or use the modeler to build a data model for your DynamoDB Table from scratch.

Have ideas or feature requests? Ping me on Twitter and let me know!