Fauna for DynamoDB users
This guide outlines major differences between Amazon DynamoDB and Fauna. The guide also translates common DynamoDB queries to Fauna Query Language (FQL) and Fauna Schema Language (FSL).
Major differences
The following table outlines major differences between DynamoDB and Fauna.
Difference | DynamoDB | Fauna |
---|---|---|
Data model |
DynamoDB is a key-value datastore. Data is stored as simple key-value pairs or as documents. |
Combines document flexibility with native relational capabilities. Stores data as denormalized and normalized JSON-like documents in collections with relationship traversals. |
Query capabilities |
Does not support joins, subqueries, aggregations, or complex filtering. |
Supports joins, subqueries, aggregations, and complex filtering through FQL. |
Indexes |
Requires a primary key that can not be changed after creation. Secondary indexes are limited to a maximum of 20 per table. Global secondary indexes (GSIs) are eventually consistent. Local secondary indexes (LSIs) can limit table performance. |
There is no primary key constraint. Indexes are strongly consistent. Fauna provides native support for secondary indexes without limitations found in DynamoDB, such as the ability to index nested fields and Arrays. Fauna does not limit the number of indexes per collection. |
Consistency |
Eventual consistency across regions with no guarantee of data consistency at any given time. Reads may not show the latest write. |
Strong consistency by default across multiple regions, continents, and cloud providers. Fauna guarantees that all reads show the latest write, even across regions. |
Distribution |
Single region. Can be configured for multi-region with global tables. |
Multi-region by default. |
Schema |
Performance heavily depends on data distribution and common access patterns. Good performance requires a well designed schema and a deep understanding of application access patterns from the start. Adapting or evolving a schema to new access patterns can requires significant work. |
Flexible schema model that allows you to adapt to new or evolving access patterns with built-in tools for zero-downtime schema migrations. FSL enables version control for schema changes, integration with CI/CD pipelines, and progressive schema enforcement as applications evolve. |
Operability |
Simple Language based on the PUT and GET HTTP methods. Logic must live in application code. Doesn’t allow you to read data and use that data in a write operation in the same transaction. |
Fauna uses FQL, a declarative Language that allows you to express complex data logic in a single query. FQL supports user-defined functions (UDF) to encapsulate logic and reuse it across queries. Allows for multi-line read, write, update operations in the same transaction. You can use reads as part of the writes/updates while keeping the transaction consistent. |
Concepts
The following table maps common concepts from DynamoDB to equivalent in Fauna.
DynamoDB | Fauna | Notes |
---|---|---|
Database |
||
Table |
||
Partition Key (Simple Primary Key) |
You can mimic some aspects of a primary key using a unique constraint and an index term. See Create a table. |
|
Partition Key and Sort Key (Composite Primary Key) |
Flexible indexing system |
You can create multiple indexes on a collection, allowing for various query patterns without being constrained to a single primary key structure. |
Index |
Fauna indexes must be named. This encourages better readability and more predictable behavior. |
Examples
The following examples compare basic operations in DynamoDB and Fauna. DynamoDB examples use the AWS CLI. Fauna examples use FQL and FSL.
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!