DynamoDB
DynamoDB is a fully managed NoSQL database service provided by AWS, designed to deliver single-digit millisecond performance at scale. It seamlessly supports applications that require consistent, low latency access to data at any scale, making it an ideal choice for high-traffic web applications, gaming platforms, mobile apps, IoT services, and more.
While you can connect the noback’s data layer to virtually any database engine, our proposal, and the default structure, is prepared to work with a single table on DynamoDB. This may be a controversial decision, specially to those who are used to relational databases.
…(meaning that any database entity will be stored on the same table with any other entities). That allow us getting data from multiple entities in a single query (when sharing partition keys), which is a huge performance improvement.
DynamoDB is all about performance and scalability. It’s a fully managed, durable database with built-in security for internet-scale applications, while being cost conscious (with default configuration, there is no expenses if there is no activity).
DynamoDB vs relational databases
There are scenarios where one might opt for a traditional relational database management system (RDBMS) over Amazon’s DynamoDB. We’ll try to cover scenarios where DynamoDB could not be the better tool.
If you are concerned about the following topics, RDBMS will probably be more suitable.
- Uncertain Access Patterns: If your application’s query patterns aren’t well-defined in advance (DynamoDB shines when access patterns are known upfront).
- Complex Relationships: For data with numerous interrelations or many-to-many relationships (Such relationships in Dynamo can become complex and less natural).
- Team expertise: Transitioning to DynamoDB requires a shift in data modeling approach, which can have a learning curve.
Key concepts
Tables, Items, and Attributes:
- Table: A collection of data. Each table contains multiple items.
- Item: Equivalent to a row in relational databases, representing a single data record.
- Attribute: Comparable to columns in relational databases, defining the data stored within an item.
Primary Keys:
- Partition Key (Hash Key): Determines data distribution across partitions.
- Sort Key (Range Key, optional): Allows efficient querying within partitions.
Indexes:
- Global Secondary Indexes (GSIs): Enable querying data with alternative partition and sort keys.
- Local Secondary Indexes (LSIs): Use the same partition key as the base table but with different sort keys.
DynamoDB data modelling
Unlike relational databases, DynamoDB is schema-less, allowing flexible data structures. However, designing your data model correctly is crucial for performance and cost efficiency:
- Design your tables based on access patterns, not normalization.
- Optimize partition keys for even data distribution.
- Minimize the number of indexes to reduce overhead and cost.
If you are interested on how to model DynamoDB tables, please refer to https://www.dynamodbbook.com
DynamoDB toolbox
On top of DynamoDB, we are using https://www.dynamodbtoolbox.com for convenience. This will allow us to create entities and methods seamlessly. More info on 🔴 database entities 🔴