DynamoDB uses the NoSQL model, which means that it is a non-relational database system. The difference between a relational database and DynamoDB is outlined in the following table:
|
SQL |
DynamoDB |
|
The SQL database system uses the persistent connection and SQL commands. |
DynamoDB uses HTTP/HTTPS requests and API operations. |
|
RDBMS's fundamental structure is a table, and its schema must be defined in advance before any operation happens on a table. |
DynamoDB uses the primary key, and a schema is not required to be defined in advance. It also uses various data sources. |
|
All table information is accessible and we can query almost all data. SQL is rich in query processing. |
Only the primary key is available for querying. To get more flexibility in querying data, one must use secondary indexes. |
|
In RDBMS, information is stored in rows of tables. |
In DynamoDB, information is stored as items in a table and the item structure can vary as it is schemaless. |
|
SQL databases use a select statement and filtering statements to load the data. |
DynamoDB uses GetItem, Query, and Scan APIs to load the data. |
|
RDBMS uses standard indexes created using a SQL statement. Changes that happen in the table are automatically managed in the indexes. |
DynamoDB uses secondary indexes for faster retrieval of data. Secondary indexes uses partition keys and sort keys. |
|
To modify table data, RDBMS uses the update statement with the set operator. |
DynamoDB uses UpdateItem to handle the update operation on table data. |
|
To delete the data from a table, RDBMS uses the delete statement. |
DynamoDB uses DeleteItem to handle the delete operation. |
|
To delete a table from the database, RDBMS uses the drop table command. |
DynamoDB uses the DeleteTable operation to handle the deletion of a table. |
|
The foreign key concept is used extensively to query data from multiple tables. |
DynamoDB has no foreign key concept. |
We shall now see the advantages of DynamoDB:
- In DynamoDB, we only have to pay for throughput and read/write operations per second, so cost-effectiveness is a key benefit of DynamoDB.
- It has the best programming support using languages such as Java, .NET and Ruby, which allow easy interaction with DynamoDB. It also provides RESTful API calls.
- It is distributed—DynamoDB scales up horizontally, and so we can distribute a single table across multiple servers.
- It is scalable—we can store any amount of data with DynamoDB. It will automatically increase storage whenever needed.
- It is flexible—DynamoDB supports a large range of data types. Its table structure is also schemaless, so new changes can be easily adopted.
- Amazon also provides a free tier account for DynamoDB, which allows 40 million operations per month.
- Amazon provides a data replication option for DynamoDB, which makes the recovery of data easier.
- DynamoDB provides a method to authenticate users through access keys and API calls. We can also use the Amazon IAM service to secure our data.
The following are some of the disadvantages of DynamoDB:
- For production use, we have to go with AWS deployment. It does not provide any software that can be installed and used in our own environment.
- When we query data, we can only access 1 MB of data at a time. To access the entirety of the data, we have to do a subsequent query operation with pagination.
- We cannot store more than 64 KB of data in a single row.
- DynamoDB does not provide support for ACID properties. We have to manually perform transaction management to achieve consistency and integrity.
- The query operation only works on a primary key. To access data more efficiently, we need to work with scan and secondary indexes.
- As DynamoDB does not support foreign keys, joins are not possible.
- Triggers are not available; instead, we have to use DynamoDB streams.