FaunaDB — The database from future

@Anil's Notes
3 min readJun 11, 2022

Note: This article covers database concepts at a very high level and requires some database background.

Problem

Do you consume Cloud providers? Did you come across this situation when your architecture diagram had many cloud services by use-case within a single product? Examples: DynamoDB for document collection needs, Redis for KV cache, Elastic Search for searching, Amazon Neptune for Graph needs, and Amazon Aurora for relational needs, and the list goes on.

As a Full-stack Software Engineer in a development team, it is really difficult to decide on the right database, explore options, chase cloud platform providers, conduct security reviews, onboard providers and then become a database expert :) and spend our time in caching, denormalization, related entities, work with the constraints of database providers that result in distracting from building a successful software product at speed & scale. Some use-cases within a product may need SQL, Document-based, or even Graph based databases but however, but there isn’t a single database solution that provides them all together.

To aggregate it all — There are few database paradigms in practice

  1. Key-Value databases: Redis and Memcache are good examples. A key point to a value. SET/GET command provides an ability to modify or retrieve data. This data modeling option is very fast but does not provide a query mechanism. Generally, this model is used for caching and super fast access to data.
  2. Wide column databases: Cassandra/Apache HBASE are good examples. It is schema-less, scales horizontally, really apt for time-series databases. Provides a CQL to query for data.
  3. Document databases: DynamoDB, MongoDB are good examples. Unstructured and schema-less provides a collection and document model. Doesn’t support joins. Writing and updating data is a bit complex. Generally used for content management, mobile apps, etc. Not useful for when there is a need for Joins.
  4. Relational databases: MySQL and Aurora are good examples. SQL — Structured query language that allows access and writing data to a relational database. Great database for Joins, however, it requires a schema i.e. you need schema upfront and changes are difficult to do. Supports ACID (atomicity, consistency, isolation, and durability) is guaranteed.
  5. Graph databases: Neo4J and Amazon Neptune are good examples. Data are represented as nodes and relationships as edges. Used for knowledge graphs, and joins.
  6. Search databases: Elastic, and Algolia are good examples. Based the Apache Lucene project, work is similar to document-based databases.

In my recent discovery & reading, I noticed that there are startups building their first MVP product in a couple of weeks, and iterating rapidly. So, I was curious about how are they managing databases, then I recently learned about the Fauna database and it Wow’d me every minute I read about it, want to know the reasons?

A new database paradigm “Multi-model” databases, Document + Relational + Graph available through one single service “FaunaDB”.

Solution

Fauna is the Cloud database, it is entirely Serverless so it doesn’t require any provision anything, it has a pay-as-you-go model with a free tier (very useful for personal or side-projects).

Fauna provides extreme flexibility, allowing you to tweak several parameters based on the requirements of your project. We can use FaunaDB as a traditional relational database, key-value, document-based or graph database. We can either enforce a schema on the data, or just let it loose.

Fauna is

  • Serverless
  • Has a free-tier
  • Amazingly fast
  • Auto-scales infinitely
  • Fauna is a developer-friendly database
  • Provides an ability to handle complex database solutions such as a relational, graph, time series, and document-based database problems.
  • Provides out-of-the-box GraphQL API for your database
  • Supports multi-tenancy
  • Tracks all changes to documents over time

Fun fact: Fauna was founded by ex-Twitter engineers

Fauna is terrific fast to develop and super fast in response time.

  1. You just need to define your GraphQL schema file to Fauna.
type Query{
userWithPosts (id: Int): [User!]!
}
type User{ name: String!
id: Int!
posts: [Post!]!
}type Post{ title: String! author: User!
}

2. Once you upload the GraphQL schema, FaunaDB automagically generates your collections to store and indexes to retrieve data.

3. GraphQL API is available for you to Query/modify data to your database.

I will write another blog post once I try FaunaDB's advanced capabilities.

--

--

@Anil's Notes

Thoughts I add here are my personal notes and learnings only