For those who didn’t heard about DynamoDB before (I know, I know, everyone loves DynamoDB but, just in case 😇) DynamoDB is an Amazon Web Services database for high-performance NoSQL applications.
DynamoDB is a wonderful solution for low-latency data access in all sorts of applications including serverless applications, mobile backends, and microservices. You can create tables in the cloud and easily insert and retrieve infinite amounts of data with DynamoDB.
Amazon DynamoDB is a true cloud-native database. It has a fairly basic programming interface, with a lot of things going on under the hood. When you create a DynamoDB table, you don’t worry about hardware level concerns like storage size, replication, sharding etc. It is all managed by the service. It is high-available by default and you can theoretically store an infinite amount of data. You never think about computation, because it is not vertically scalable - it scales horizontally, just like how every high-available cloud resource should be. You don’t design the resource, it is already designed to perform at the best level.
A primary key is used to identify each item in a table. When creating a table, the primary key must be defined and must be provided when inserting a new item. In our example below, “103” is a primary key.
DynamoDB supports two different kinds of primary keys, simple primary key and composite primary key. A simple primary key is made up of simply a partition key, whereas a composite primary key is made up of both a partition key and a sort key.
Using a simple primary key is equal to using standard key-value stores or using a primary key to retrieve data in a SQL table. Composite primary key is a tad bit dirty, you define both a partition key and a sort key with it. The sort key is used to sort items that belong to the same partition.
It is good to remember that even with the composite key, each item in a table is uniquely identified by a primary key. You can have many items with the same partition key but different sort keys when using a database with a composite primary key. With a specific partition key and sort key combination, you can only have one item. Also, composite primary key enable sophisticated query patterns, such as collecting all items with a specific partition key or narrowing the relevant items for a query using the sort key.
What if you want to filter your data by another attribute in a table? This is where secondary indexes shine. Additional indexes allowing you to design queries that search your data by various attributes.
You've probably used indexes with relational databases if you've worked with them. However, there are a few significant variations in how indexes work in DynamoDB. To begin, each query is limited to using only one index. You'll need to establish an index that can query and match on two different columns if you wish to do it correctly. Secondly, you must specify which index should be used for each query when writing your queries. It's not like a relational database with a query analyzer that can pick which indexes to use for our query automatically. So, you must be clear here and tell DynamoDB which index to use.
There are two types of secondary indexes in DynamoDB. You can use global secondary indexes to search throughout the entire table for any record that matches a specific value. Local secondary indexes, on the other hand, can only help find data within a particular partition key.
Thanks to DynamoDB, questions like how many CPUs do we need, how much RAM, how many GBs of storage are now belong to history. We don’t need to provision a particular server to run a database. Instead, we provision read and write capacity units. These units allow a given number of operations per second.
The read/write capacity mode controls how you are charged for read and write throughput and how you manage capacity. DynamoDB also autoscales read and write capacity units. So, you can save money when it is dawn and also scale up when a need arises. 🌗
Thank you for reading this post and stay tuned for more!
A technology nerd, specializing in interpreting data and marketing, Melih is eager to learn and share his knowledge of business technologies. He is always extremely curious to learn more about how technology impacts organizations.
We believe in the power of technology when it comes to success. We help our clients to keep up with the best practices in technology for their custom business needs while improving the way they work.
Cookies are small files that are sent to and stored in your computer by the websites you visit. Next time you visit the site, your browser will read the cookie and relay the information back to the website or element that originally set the cookie.
Cookies allow us to recognize you automatically whenever you visit our site so that we can personalize your experience and provide you with better service.