Mapping of DynamoDB table to Oracle NoSQL table
In DynamoDB, a table is a collection of items, and each item is a collection of attributes. Each item in the table has a unique identifier, or a primary key. Other than the primary key, the table is schema-less. Each item can have its own distinct attributes.
DynamoDB supports two different kinds of primary keys:
- Partition key – A simple primary key, composed of one attribute known as the partition key. DynamoDB uses the partition key's value as input to an internal hash function. The output from the hash function determines the partition in which the item will be stored.
- Partition key and sort key – As a composite primary key, this type of key is composed of two attributes. The first attribute is the partition key, and the second attribute is the sort key. DynamoDB uses the partition key value as input to an internal hash function. The output from the hash function determines the partition in which the item will be stored. All items with the same partition key value are stored together, in sorted order by sort key value.
In contrast, Oracle NoSQL tables support flexible data models with both schema and schema-less design.
There are two different ways of modelling a DynamoDB table:
- Modeling DynamoDB table as a JSON document(Recommended):
In this modeling, you map all the attributes of the Dynamo
DB tables into a JSON column of the NoSQL table except
partition key and sort key. You will model partition key and
sort key as the Primary Key columns of the NoSQL table. You
will use
AggregateFields
transform in order to aggregate non-primary key data into a JSON column.Note:
The Migrator provides a user-friendly configurationdefaultSchema
to automatically create a schema-less DDL table which also aggregates attributes into a JSON column. - Modeling DynamoDB table as fixed columns in NoSQL table:
In this modeling, for each attribute of the DynamoDB
table, you will create a column in the NoSQL table as
specified in the Mapping of DynamoDB types to Oracle NoSQL types. You will model partition key and sort key attributes as
Primary key(s). This should be used only when you are
certain that importing DynamoDB table schema is fixed and
each item has values for the most of the attributes. If
DynamoDB items do not have common attributes, this can
result in lot of NoSQL columns with empty values.
Note:
We highly recommend using schema-less tables when migrating data from DynamoDB to Oracle NoSQL Database due to the nature of DynamoDB tables being schema-less. This is especially for large tables where the content of each record may not be uniform across the table.