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 '
Click the binoculars '
Click the back '
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 '
- On the Table Name tab to create a new index:
- In the Primary Key header cell to add a new partition:
- In a Partition Key value cell to add a new item to a partition:
- In a Sort Key value cell to add a new attribute to an Item:
Finally, click the minus '
- In a Partition Key value cell to delete a partition and all Items in it:
- 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 '
Clicking the add '
Changing the "type" attribute value will cause the Item to be annoted with attributes from the corresponding Item template:
Clicking the add '
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:
- Add Item - Adds a new Item to the partition.
- Paste Item - Adds a copied Item to the partition.
- Delete Partition - Deletes all Items in this partition from the table.
- Edit Value Template - Define a value template to generate the Partition Key value.
- Move Up/Down - Change the position of the partition on the table.
Sort Key Menu
The Sort Key Context Menu contains the following options:
- Add Attribute - Adds a new Attribute to the Item.
- Cut Item - Removes the Item from the Table and copies it to the clipboard.
- Copy Item - Copies the Item to the clipboard.
- Delete Item - Removes the Item from the Table.
- Edit Value Template - Define a value template to generate the Sort Key value.
- 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:
- Delete Attribute - Removes the Attribute from the Item.
- Cut Item - Removes the Item from the Table and copies it to the clipboard.
- Edit Value Template - Define a value template to generate the Attribute value.
- 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!