Frequently Asked Questions

Choosing Datomic

What kind of database is Datomic?

Datomic is a general-purpose, ACID, datalog database that stores immutable facts (datoms) accumulating over time. This information model enables arbitrary horizontal read scaling and affinity for distributed architectures.

For more, see the Rationale and Overview.

How much does Datomic cost?

All editions of Datomic are free of licensing fees. Datomic binaries are released under Apache 2.0 and available via Maven Central, with no signup required. With Datomic Cloud you pay AWS only for the infrastructure you provision; Datomic has no additional software cost.

What sorts of applications is Datomic designed for?

Datomic is a good fit for systems of record that must explain themselves. It’s especially well suited to provide read scalability, audit capabilities, access to history, and developer and operational flexibility.

Examples of successful Datomic use cases include banking, transactional data, business, medical, scientific or financial records, and logistics and inventory management.

What sort of applications is Datomic not a good fit for?

Datomic is not a good fit for applications that need unlimited write scalability or as storage for large, unstructured data (e.g. BLOBs or media files).

What is Datomic’s consistency model? Does Datomic support ACID transactions?

Datomic is consistent in both the CAP and ACID sense. Datomic transactions are always ACID. All transactions are serialized and all reads are guaranteed to be consistent. See the ACID docs and the Jepsen test report with its companion blog post.

Can Datomic be used by applications running on any OS?

Yes, Datomic is OS-agnostic. The only requirements are an application using one of the Datomic client libraries and HTTP access to the Datomic system.

Will I be locked in to Datomic?

No. The data in Datomic can be exported via datalog queries or direct index access to a file and format of your choice.

Will you publish the client protocol so I can write my own Datomic client?

We intend to publish the specification for the Client wire protocol once it has been finalized. In an effort to prevent future breaking changes to the protocol, we are gathering information and user experience details prior to finalizing the specification.

What are the different kinds? Which one is right for me?

Datomic comes in three editions:

  • Datomic Pro — A distributed database with arbitrary read scaling, pluggable storage, and the ability to run on-premises or in the cloud.

  • Datomic Cloud — Available on the Amazon Marketplace, deploying into your AWS account with usage-based billing.

  • Datomic Local — An embedded, single-process database. No separate server or network overhead.

What is the relationship between Cognitect, Nubank, and Datomic?

Datomic is developed by Nu North America, Inc (formerly Cognitect).

Datomic development, product offerings, customer relationships and trade secrets remain independent from Nubank. Nu North America, Inc continues to offer professional services and support for Datomic customers. See the Contact page.

As Datomic’s patron, Nubank is well served by Datomic’s continued adoption at other companies. Datomic will continue to be developed as a commercially available, general-purpose database, rather than being restricted to internal use.

How is Datomic different from a traditional RDBMS? A NoSQL database?

Unlike traditional RDBMSs, Datomic’s architecture separates storage, transactions, and query. Datomic’s data model is based upon a universal primitive relation, of datoms, rather than an arbitrary set of named relations. The query model, while relational, is based upon Datalog, not SQL. Datomic has weaker constraint capabilities than some RDBMS, but more flexible data modeling. It shares ACID transactions and arbitrary joins.

Most NoSQL databases sacrifice transactionality and join capability and adopt sharding and eventual consistency. They also often have data models not supported by relational logic. Datomic trades off arbitrary write scalability to retain arbitrary transactions and joins. It provides a strong data model and powerful query with arbitrary read and query scaling.

How does Datalog differ from SQL?

Datalog is a deductive query system combining a database of facts (the Datomic db) with a set of rules for deriving new facts from existing facts and other rules. This query capability is combined with a powerful hierarchical selection facility (pull), so you can recover tree-like data without joins or complex re-assembly. Datalog with negation is of equivalent power to relational algebra with recursion. Datalog is a great fit for application queries thanks to:

  • Pattern-matching structures which make joins implicit and performant

  • Recursion being much more straightforward than in SQL

  • Logic-oriented rules similar to SQL views but aligned more closely with business logic

How big can a database be?

While there is no explicit limit, database performance will degrade beyond approximately 10 billion total datoms. Larger data sets can be split across multiple databases.

Is enterprise support available?

Enterprise support is available separately. Contact us at sales@cognitect.com if you require

  • customized license terms outside or beyond our standard EULA, or

  • 24x7 access to technical support for critical deployments

Modeling & Developing

What is a datom?

A datom (pronounced like “datum”; plural “datoms”) is an atomic fact representing the addition or retraction of a relation between an entity, an attribute, a value, and a transaction.

A datom is expressed as a five-tuple:

  1. An entity id

  2. An attribute

  3. A value for that attribute

  4. A transaction id

  5. A boolean indicating whether the datom is being added or retracted

Datoms are the fundamental building blocks of Datomic’s data model.

What is Datomic’s data model?

Datomic is a database of immutable facts (not places). While many queries might be interested in the 'current' facts, others might be interested in, e.g. what the product catalog looked like last month compared to this month. Incorporating time in data allows the past to be retained (or not), and supports point-in-time queries. Many real world systems have to retain all changes, and struggle mightily to efficiently provide the 'latest' view in a traditional database. This all happens automatically in Datomic.

A Datomic database is just a set of datoms, indexed in various ways. These indexes contain all of the data, not pointers to data (i.e. they are covering indexes). The storage service and caches are just a distribution network for the data segments of these indexes, all of which are immutable, and thus effectively and coherently cached.

The flexibility provided by Datomic’s simple data model empowers modeling many different data types naturally. The Universal Relation handles row-shaped, column-shaped, graph-like, and document-like data modeling equally well. Applications written to this model are free of the structural rigidity of relational and document models.

Does Datomic have tables?

No. Datomic’s Universal Relation—where any entity can have any set of attributes—eliminates the need for tables. Queries can interrogate any set of entities without needing to resort to join tables or other mapping strategies.

What data types are supported by Datomic?

Datomic supports a variety of scalar and collection datatypes. The Programming with Data and EDN docs provides details on all supported data types.

Does Datomic support schema-less data?

No. All databases have a schema, whether they are explicit (i.e. traditional relational databases) or inferred (i.e, so-called schema-less databases). Rigidity arises in systems to the extent that the schema pervades the storage representation or application access patterns, making changes to your tables or documents difficult.

The schema required to encode datoms is minimal, consisting primarily of the attribute definitions which specify name, type, and cardinality. The advantage of an explicit flexible schema definition is that it provides power to your system:

  • Power to efficiently access the data (via query)

  • Power to directly model the domain structure of your data

  • Power to reason about the representation of the data in the database

How do I create my schema?

Datomic schema uses the same data model as application data itself — attributes are entities with associated attributes. Define schema by transacting attribute entity definitions. See the official schema documentation for examples.

How should I model my data in Datomic?

Datomic’s flexible universal schema and multiple spanning indexes support row-oriented, column-oriented, document-oriented, key-value, and graph-like data modeling. See the Data Modeling section of the documentation for guidance.

How do I prevent users from adding invalid data?

Datomic provides several built-in mechanisms: ACID semantics, uniqueness constraints, schema value types, and functional (transaction) constraints. These features reject invalid transactions at the database level before they are committed.

Does Datomic support conditional operations?

Yes, Datomic includes a built-in transaction function :db.fn/cas for compare-and-swap (cas), enabling atomic conditional updates. See Built-In Transaction Functions for details.

What indexes does Datomic use?

Datomic automatically maintains a set of multiple covering indexes. These indexes each contain all of the datoms in the database, sorted in different orders, to provide efficient access to the data via multiple access patterns, including row-oriented, column-oriented, document-oriented, K/V, and graph. More information about Datomic’s indexes can be found in the Indexes docs.

Can I remove an index?

No. Datomic’s built-in covering indexes are automatic, essential for efficient queries regardless of access pattern, and cannot be disabled or removed.

Don’t all those indexes take up a lot of storage space?

Datomic uses an efficient data representation (fressian), which is further compressed prior to storage. Given substantial decreases in storage costs, the Datomic design chooses to use slightly more storage space to provide a substantially more performant system.

Further, Datomic does not pay any penalty for sparse data: the absence of a given attribute on an entity does not require a null value.

Against which index should I target my query?

The Datalog query engine automatically selects the most efficient index.

Some APIs like datoms, seek-datoms, or index-pull require an explicit index.

Does Datomic use sharding?

No. Unlike with sharding, Datomic data can be read and queried from any node. However, you can route requests so that groups develop hot caches for different workloads. This provides horizontal scaling without the compromises typically associated with sharding. In particular:

  • You make no up-front decisions about where data will live.

  • Your programming model is not polluted by any awareness of where data lives.

  • At any time (and long after transacting your data), you can start new groups and route queries to them.

Is there a way to translate an attribute id to the corresponding ident?

Yes, using Datomic queries:

;; Get ident name from entity ID
(defn ident-name [conn eid]
  (ffirst (d/q '[:find ?v :in $ ?eid :where [?eid :db/ident ?v]]
               (d/db conn) eid)))

;; Get entity ID from ident name
(defn ident-id [conn ident]
  (ffirst (d/q '[:find ?eid :in $ ?v :where [?eid :db/ident ?v]]
               (d/db conn) ident)))

;; Pull full entity by ID
(defn pull-eid [conn eid]
  (ffirst (d/q '[:find (pull ?eid [*]) :in $ ?eid]
               (d/db conn) eid)))

How do I query Datomic?

Datomic uses Datalog, a logic-based query langage. Like SQL, Datalog is a declarative query language, meaning you specify what you want to know, but not how to find it. A Datalog system includes a database of facts (your Datomic database) and a set of rules.

The Datomic Query Engine takes a partially specified set of facts or rules and finds all instances of the specification implied by the database and rules. The Executing Queries page describes the fundamentals of buiding a Datomic Query.

How do I perform transactions with Datomic?

Datomic represents transactions as data structures, not strings, making it easy to build requests programmatically.

The Processing Transactions section of the docs provides details on syntax and usage of Datomic transactions.

How do I import an existing dataset?

The mbrainz-importer library on GitHub serves as a reference implementation demonstrating practical patterns for importing existing data into Datomic.

Where can I find examples of Datomic usage?

The Examples page of the Datomic Documentation contains links to several example projects that use Datomic.

How do I get started using Datomic?

See the Get Started page for a guided tutorial, or the official documentation for comprehensive setup instructions.

How can I get help using Datomic?

The primary resource is the Datomic Documentation. For community support, see the Contact page — including the Datomic forum, Clojurians Slack, and the support ticket system.

When will feature X be available?

We prefer not to discuss new features prior to their public release.

Datomic Cloud

What software & services does Datomic Cloud run on?

Datomic Cloud runs on Amazon EC2 and uses DynamoDB, Elastic File System (EFS), Simple Storage Service (S3), and several other AWS services.

In which AWS regions is Datomic Cloud available?

Datomic Cloud is available in Supported Regions. Organizations interested in other regions for Datomic Cloud should contact Datomic directly.

Can Datomic be hosted in the same region as my application?

Yes — Datomic Cloud can be deployed in any supported AWS region. Running it in the same region as your application optimizes latency and performance.

When will Datomic Cloud be available anywhere other than AWS?

Datomic Cloud is built with many individual AWS services and relies on specific semantic and operational characteristics of these services. It is unlikely that an infrastructure-agnostic version of Datomic Cloud will be developed.

If you have a requirement to run somewhere other than AWS, Datomic Pro can be deployed anywhere.

Do Ions support integration with other AWS services?

Ions are functions that run in the same JVM as your Datomic Cloud system. They can contain arbitrary Clojure code, including using external AWS services. You will need to configure your Ions using AWS IAM policies to grant them the AWS permissions necessary for their specific uses of other AWS services.

What is the size limit of a Datomic Cloud database?

There is no hard limit on the size of an individual Datomic database. However, running databases with a total history of more than 10 billion datoms may introduce a number of operational considerations. If your use case is likely to require more than 10 billion datoms, we would encourage you to contact us to discuss your system and optimize your deployment strategy.

What are the scaling limits of Datomic Cloud?

There are no limits for reads. You can scale reads horizontally by

  • autoscaling the number of instances in a query group, and/or

  • explicitly launching additional query groups

Writes to a single database are limited by the serial nature of Datomic transactions. This limit will typically only be encountered during bulk data import.

How many databases can I have in a single Datomic Cloud system?

While there is no specific limit on the number of logical databases supported by a single Datomic Cloud system, each database requires some amount of memory and computational overhead on all instances in the primary compute group. A Datomic Cloud system should contain the database(s) for a specific purpose, and you should create separate systems for databases that serve separate purposes. The system planning documentation provides additional details to aid in overall system design and configuration.

How do I scale the computing resources associated with Datomic Cloud?

Datomic Cloud handles scaling automatically. Datomic’s Scaling Topology will automatically add and remove EC2 instances from a Datomic cluster based on CPU utilization, within limits you control.

Moreover, you can start additional groups serving the same system, and route different tasks to different groups. For example, you might have separate groups for transactional load, analytics queries, and support.

If I build a system on version X, can I port it to version Y?

Both Datomic Cloud and Datomic Pro support the same Client API, so applications are compatible with either. However, Datomic Cloud doesn’t support the Peer Library, and Datomic doesn’t provide a seamless process for moving databases between Cloud and Pro; see Moving To Cloud documentation for guidance.

When should I increase the number of instances in the primary compute group?

You should NOT enable AWS Auto Scaling on the primary compute group. However, if you frequently write heavily to a larger number of databases than the number of instances in the compute group, you may wish to manually increase the overall size of the compute group to be equal to or slightly larger than the number of databases with significant write load.

How does Datomic Cloud minimize recovery time during failover?

The Scaling Topology distributes load across multiple compute instances. In the event of an instance failure, an Application Load Balancer (ALB) will remove the instance, distributing work to the remaining instances while a new instance spins up. Databases remain available throughout an instance failover, with incrementally degraded performance.

How does Datomic Cloud improve fault tolerance to disk failures?

Datomic Cloud has no single points of failure, either of machines or of disks. Datomic Cloud uses AWS storage services that provide the strongest guarantees of throughput and fault tolerance:

  • Datomic stores the database log in DynamoDB

  • Datomic stores indexes in S3

Can I temporarily "turn down" my Datomic Cloud system when it is not in use?

Yes, in Datomic Cloud you can turn down your Auto Scaling Group to shut down compute or query groups without deleting any resources, reducing costs during periods of inactivity.

Can we control the data storage region?

Datomic Cloud runs entirely within your AWS account in a single AWS region. Datomic will only provision AWS resources in the region in which you create your system.

Can we choose the backend storage?

No — Datomic uses a stratified storage stack, automatically leveraging redundant layers across S3, DynamoDB, EFS, local disk, and memory to deliver its semantic and operational guarantees and optimize reliability and performance.

Is there an "offline" option for testing & development?

Use Datomic Local to develop and test applications with minimal connectivity and setup. Specifically, divert-system enables development and testing of Datomic Cloud applications without connecting to a server and without changing your application code, making it suitable for local development and testing before deploying to production.

I can’t connect to my Datomic database.

Consult the troubleshooting guide, which covers common problems accessing Datomic.

What is Amazon Virtual Private Cloud and how does it work with Datomic?

Amazon VPC lets you create a virtual networking environment in a private, isolated section of the AWS cloud, where you can exercise complete control over aspects such as private IP address ranges, subnets, routing tables and network gateways. Datomic Cloud always runs in a VPC, so you can keep your backend isolated from the public internet.

Does Datomic Cloud provide SSL/HTTPS access?

Datomic is always accessed through an Application Load Balancer (ALB) that exposes only HTTPS.

How do I set up users and permissions?

You can control read and write access at the database level using IAM policies.

How safe is my data?

Datomic uses AWS best practices for securing data. Data is stored in highly-reliable services: DynamoDB and S3. Data is always encrypted using AES-256 at rest, and keys are managed via the AWS Key Management Service (KWS).

Can Datomic encrypt sensitive data such as PHI or PII?

Yes. All Datomic data is encrypted at rest using keys managed by AWS KMS, addressing encryption requirements for regulated environments handling protected health information (PHI) and personally identifiable information (PII).

How much does Datomic Cloud cost?

Datomic is free. Datomic Cloud has no Datomic license fee. You pay the AWS usage costs for the topology and instance types you run, as listed on the AWS Marketplace product page. Charges incurred for running Datomic Cloud are included in your monthly AWS bill.